小程序控件实现长按事件代码记录
<button class="btn-regist" @click="test3()" @touchstart="test1" @touchend="test2">测试</button>
<script>
method:{
test1(){
console.log('开始按下')
this.clickFlag = true
this.timer = setTimeout(()=>{
console.log('触发事件')
this.clickFlag = false
},1000)
},
test2(){
if(this.timer){
clearTimeout(this.timer)
}
},
test3(){
if(this.clickFlag)
console.log('click触发')
},
}
</script>