vue中常用事件-touchstart和touchend
鼠标事件(pc,移动端都触发): click
触摸事件(移动端): touchstart(点击),touchend(弹起),touchmove(滑动)
文本框事件: change,input
touchstart和touchend配合定时器共同使用,实现移动端长按效果
start() {
//清除定时器,防止多次点击
clearTimeout(this.timer)
this.timer = setTimeout(()=> {
console.info('长按')
//可调用自定义方法
}, 800)
},
click() {
console.info('click me')
},
end() {
clearTimeout(this.timer)
},
若在移动端,同时存在touchstart,click 事件,先触发touchstart