html
<div class="test" @touchstart="gtouchstart()">按啊</div>
js
data(){
return {
timeOutEvent: 0 ,// 长按事件定时器
}
}
methods: { gtouchstart () { // 开始触摸 this.timeOutEvent = setTimeout(() => { // 长按2秒 this.timeOutEvent = 0 alert('ggg') }, 2000) }, }
2024-02-12 17:15:10
html
<div class="test" @touchstart="gtouchstart()">按啊</div>
js
data(){
return {
timeOutEvent: 0 ,// 长按事件定时器
}
}
methods: { gtouchstart () { // 开始触摸 this.timeOutEvent = setTimeout(() => { // 长按2秒 this.timeOutEvent = 0 alert('ggg') }, 2000) }, }