mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
[improvement] rename packages dir to src (#3659)
This commit is contained in:
65
src/number-keyboard/Key.js
Normal file
65
src/number-keyboard/Key.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import { createNamespace } from '../utils';
|
||||
|
||||
const [createComponent, bem] = createNamespace('key');
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
type: String,
|
||||
theme: Array,
|
||||
text: [String, Number]
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
active: false
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
className() {
|
||||
const classNames = this.theme.slice(0);
|
||||
|
||||
if (this.active) {
|
||||
classNames.push('active');
|
||||
}
|
||||
|
||||
if (this.type) {
|
||||
classNames.push(this.type);
|
||||
}
|
||||
|
||||
return bem(classNames);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onFocus() {
|
||||
this.active = true;
|
||||
},
|
||||
|
||||
onBlur(event) {
|
||||
this.active = false;
|
||||
},
|
||||
|
||||
onClick() {
|
||||
this.$emit('press', this.text, this.type);
|
||||
}
|
||||
},
|
||||
|
||||
render(h) {
|
||||
const { onBlur } = this;
|
||||
return (
|
||||
<i
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class={['van-hairline', this.className]}
|
||||
onClick={this.onClick}
|
||||
onTouchstart={this.onFocus}
|
||||
onTouchmove={onBlur}
|
||||
onTouchend={onBlur}
|
||||
onTouchcancel={onBlur}
|
||||
>
|
||||
{this.slots('default') || this.text}
|
||||
</i>
|
||||
);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user