diff --git a/src/mixins/touch.ts b/src/mixins/touch.ts index 55b6999ff..01bddb42c 100644 --- a/src/mixins/touch.ts +++ b/src/mixins/touch.ts @@ -61,8 +61,11 @@ export const TouchMixin = Vue.extend({ const { onTouchStart, onTouchMove, onTouchEnd } = (this as any); on(el, 'touchstart', onTouchStart); on(el, 'touchmove', onTouchMove); - on(el, 'touchend', onTouchEnd); - on(el, 'touchcancel', onTouchEnd); + + if (onTouchEnd) { + on(el, 'touchend', onTouchEnd); + on(el, 'touchcancel', onTouchEnd); + } } } }); diff --git a/src/rate/index.js b/src/rate/index.js index 3cfa29e0b..980db4c3c 100644 --- a/src/rate/index.js +++ b/src/rate/index.js @@ -79,6 +79,10 @@ export default createComponent({ } }, + mounted() { + this.bindTouchEvent(this.$el); + }, + methods: { select(index) { if (!this.disabled && !this.readonly && index !== this.value) { @@ -137,7 +141,15 @@ export default createComponent({ }, genStar(status, index) { - const { icon, color, count, voidIcon, disabled, voidColor, disabledColor } = this; + const { + icon, + color, + count, + voidIcon, + disabled, + voidColor, + disabledColor + } = this; const score = index + 1; const isFull = status === 'full'; const isVoid = status === 'void'; @@ -189,13 +201,7 @@ export default createComponent({ render() { return ( -