uniapp 监听手指的操作 并 阻止冒泡行为,防止父子联动

143 阅读1分钟

手指滑动事件关键点在于三个事件:

1、@touchstart :触摸开始;
2、@touchmove:手指滑动的过程;
3、@touchend:触摸结束,手指离开屏幕。

使用

<view @touchstart="start"><view>

有时候在父盒子上面添加了 上面的 三个事件,然后子盒子上会有相同的行为出来,然后父盒子也会跟着触发,导致和预想的效果不一样,以触摸结束事件为例,这时候可以在子盒子上使用 @touchend.stop.prevent 来阻止该行为

使用

<view class="table"  @touchend.stop.prevent></view>