mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Rate、Slider): avoid Vue 2.6 event bubble issues (#5350)
This commit is contained in:
parent
c3685ac7c1
commit
cd6050d3e4
@ -61,8 +61,11 @@ export const TouchMixin = Vue.extend({
|
|||||||
const { onTouchStart, onTouchMove, onTouchEnd } = (this as any);
|
const { onTouchStart, onTouchMove, onTouchEnd } = (this as any);
|
||||||
on(el, 'touchstart', onTouchStart);
|
on(el, 'touchstart', onTouchStart);
|
||||||
on(el, 'touchmove', onTouchMove);
|
on(el, 'touchmove', onTouchMove);
|
||||||
on(el, 'touchend', onTouchEnd);
|
|
||||||
on(el, 'touchcancel', onTouchEnd);
|
if (onTouchEnd) {
|
||||||
|
on(el, 'touchend', onTouchEnd);
|
||||||
|
on(el, 'touchcancel', onTouchEnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -79,6 +79,10 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.bindTouchEvent(this.$el);
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
select(index) {
|
select(index) {
|
||||||
if (!this.disabled && !this.readonly && index !== this.value) {
|
if (!this.disabled && !this.readonly && index !== this.value) {
|
||||||
@ -137,7 +141,15 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
genStar(status, index) {
|
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 score = index + 1;
|
||||||
const isFull = status === 'full';
|
const isFull = status === 'full';
|
||||||
const isVoid = status === 'void';
|
const isVoid = status === 'void';
|
||||||
@ -189,13 +201,7 @@ export default createComponent({
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div class={bem()} tabindex="0" role="radiogroup">
|
||||||
class={bem()}
|
|
||||||
tabindex="0"
|
|
||||||
role="radiogroup"
|
|
||||||
onTouchstart={this.onTouchStart}
|
|
||||||
onTouchmove={this.onTouchMove}
|
|
||||||
>
|
|
||||||
{this.list.map((status, index) => this.genStar(status, index))}
|
{this.list.map((status, index) => this.genStar(status, index))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -51,6 +51,10 @@ export default createComponent({
|
|||||||
this.updateValue(this.value);
|
this.updateValue(this.value);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.bindTouchEvent(this.$refs.wrapper);
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onTouchStart(event) {
|
onTouchStart(event) {
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
@ -157,6 +161,7 @@ export default createComponent({
|
|||||||
>
|
>
|
||||||
<div class={bem('bar')} style={barStyle}>
|
<div class={bem('bar')} style={barStyle}>
|
||||||
<div
|
<div
|
||||||
|
ref="wrapper"
|
||||||
role="slider"
|
role="slider"
|
||||||
tabindex={this.disabled ? -1 : 0}
|
tabindex={this.disabled ? -1 : 0}
|
||||||
aria-valuemin={this.min}
|
aria-valuemin={this.min}
|
||||||
@ -164,10 +169,6 @@ export default createComponent({
|
|||||||
aria-valuemax={this.max}
|
aria-valuemax={this.max}
|
||||||
aria-orientation={this.vertical ? 'vertical' : 'horizontal'}
|
aria-orientation={this.vertical ? 'vertical' : 'horizontal'}
|
||||||
class={bem('button-wrapper')}
|
class={bem('button-wrapper')}
|
||||||
onTouchstart={this.onTouchStart}
|
|
||||||
onTouchmove={this.onTouchMove}
|
|
||||||
onTouchend={this.onTouchEnd}
|
|
||||||
onTouchcancel={this.onTouchEnd}
|
|
||||||
>
|
>
|
||||||
{this.slots('button') || <div class={bem('button')} />}
|
{this.slots('button') || <div class={bem('button')} />}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user