diff --git a/src/number-keyboard/Key.js b/src/number-keyboard/Key.js
index 34c424254..9f2b7b709 100644
--- a/src/number-keyboard/Key.js
+++ b/src/number-keyboard/Key.js
@@ -1,13 +1,12 @@
+import { ref } from 'vue';
import { createNamespace } from '../utils';
-import { TouchMixin } from '../mixins/touch';
-import { DeleteIcon, CollapseIcon } from './Icon';
+import { useTouch } from '../composition/use-touch';
import Loading from '../loading';
+import { DeleteIcon, CollapseIcon } from './Icon';
const [createComponent, bem] = createNamespace('key');
export default createComponent({
- mixins: [TouchMixin],
-
props: {
type: String,
text: [Number, String],
@@ -19,79 +18,69 @@ export default createComponent({
emits: ['press'],
- data() {
- return {
- active: false,
+ setup(props, { emit, slots }) {
+ const active = ref(false);
+ const touch = useTouch();
+
+ const onTouchStart = (event) => {
+ touch.start(event);
+ active.value = true;
};
- },
- mounted() {
- this.bindTouchEvent(this.$el);
- },
-
- methods: {
- onTouchStart(event) {
- // compatible with Vue 2.6 event bubble bug
- event.stopPropagation();
-
- this.touchStart(event);
- this.active = true;
- },
-
- onTouchMove(event) {
- this.touchMove(event);
-
- if (this.direction) {
- this.active = false;
+ const onTouchMove = (event) => {
+ touch.move(event);
+ if (touch.direction) {
+ active.value = false;
}
- },
+ };
- onTouchEnd(event) {
- if (this.active) {
+ const onTouchEnd = (event) => {
+ if (active.value) {
// eliminate tap delay on safari
event.preventDefault();
- this.active = false;
- this.$emit('press', this.text, this.type);
+ active.value = false;
+ emit('press', props.text, props.type);
}
- },
+ };
- genContent() {
- const isExtra = this.type === 'extra';
- const isDelete = this.type === 'delete';
- const text = this.$slots.default ? this.$slots.default() : this.text;
-
- if (this.loading) {
+ const renderContent = () => {
+ if (props.loading) {
return