【uni-app】长按事件
<view@touchmove="handletouchmove" @touchstart="handletouchstart" @touchend="handletouchend" ></view>handletouchstart(e) {this.timeOutEvent = setTimeout(() => {this.onLongPress(
·
<view @touchmove="handletouchmove" @touchstart="handletouchstart" @touchend="handletouchend" >
</view>
handletouchstart(e) {
this.timeOutEvent = setTimeout(() => {
this.onLongPress(e)
}, 1000); //这里设置定时器,定义长按1000毫秒触发长按事件,时间可以自己改,
return false;
},
handletouchend() {
clearTimeout(this.time); //清除定时器
if (this.time != 0) {
//处理点击时间
}
return false;
},
handletouchmove() {
clearTimeout(this.time); //清除定时器
this.time = 0;
},
onLongPress(e) {
// 处理长按事件
}
更多推荐
已为社区贡献14条内容
所有评论(0)