<div class="a" @touchstart="touchStart()" @touchend="touchEnd()" @click="adb()" style="height:30px;width:90px;text-align: center;background-color: gainsboro;">长按我</div>
data(){
return {
loop:null,
}
},
methods:{
adb(){
console.log(13)
},
touchEnd(){
//手指离开
console.log(1)
clearTimeout(this.Loop);
},
touchStart(){
//手指触摸
clearTimeout(this.Loop); //再次清空定时器,防止重复注册定时器
this.Loop = setTimeout(function() {
console.log(1222)
},3000)
},
}