vue长按和点击共存
<div>
<div @touchstart.prevent="touchin()" @touchend.prevent="clickhandle()" ></div>
</div>
data() {
return {
Loop:0
}
},
methods: {
touchin(index){ // 长按事件,按住后等待指定事件触发
let that=this;
this.Loop = setTimeout(function() {
that.Loop = 0;
console.log("长按触发")
}, 500);
return false;
},
clickhandle() { // 模拟点击事件(点击后迅速抬起)
let that=this;
clearTimeout(this.Loop);
if(that.Loop!==0){
console.log("点击事件")
}
return false;
}
}
您还未登录, 登录 后可进行评论
发表
还没有评论哦,来抢个沙发吧!