<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) {  
         // 处理长按事件  
}  
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐