mirror of
https://github.com/youzan/vant.git
synced 2025-12-24 02:02:09 +08:00
[new feature] NumberKeyboard add custom theme (#472)
This commit is contained in:
49
packages/number-keyboard/Key.vue
Normal file
49
packages/number-keyboard/Key.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<i
|
||||
v-text="text"
|
||||
@touchstart.stop.prevent="onFocus"
|
||||
@touchmove="onBlur"
|
||||
@touchend="onBlur"
|
||||
@touchcancel="onBlur"
|
||||
class="van-hairline van-key"
|
||||
:class="className"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
text: [String, Number],
|
||||
type: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
active: false
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
className() {
|
||||
const types = this.type.slice(0);
|
||||
this.active && types.push('active');
|
||||
|
||||
return types.map(type => `van-key--${type}`);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onFocus() {
|
||||
this.active = true;
|
||||
this.$emit('press', this.text);
|
||||
},
|
||||
|
||||
onBlur() {
|
||||
this.active = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user