安装模块
npm i @vant/touch-emulator -S
main.js引入
import '@vant/touch-emulator';
van-swipe-cell 滑动阻止冒泡失效
<van-swipe-cell :stop-propagation="true" @open="open" @close="open">
<template #left>
<van-button square type="primary" text="选择" />
</template>
<van-cell @click="touchstartFn" :border="false" title="单元格" value="内容" />
<template #right>
<van-button square type="danger" text="删除" />
<van-button square type="primary" text="收藏" />
</template>
</van-swipe-cell>
// 在data内定义变量
data(){
return{
offClick: false
}
}
methods: {
// 滑动和关闭同一方法,改变状态阻止列表点击事件
open(){
this.offClick = true
},
// 列表点击事件
touchstartFn() {
if (!this.offClick) {
// 这里是自己的逻辑
} else {
this.offClick = false;
}
}
}