uni-app applet double click event

uni-app applet double-click event

At present, the uni-app view tag does not support double-click events, and the following custom double-click events:

// A code block
<view  @click="handClick(index)"></view>
data(){
    
    
  return {
    
    
    lastTapTimeoutFunc:null,
	lastTapDiffTime:0
  }
},

methods:{
    
    
// 单击或双击
handClick(index) {
    
    
  let _this = this;
  let curTime = new Date().getTime();
  let lastTime = _this.lastTapDiffTime;
  _this.lastTapDiffTime = curTime;
  //两次点击间隔小于300ms, 认为是双击
  let diff = curTime - lastTime;
  if (diff < 300) {
    
    
   	console.log("双击")
   	//_this.handleVideo('screen',index)自定义事件
   clearTimeout(_this.lastTapTimeoutFunc); // 成功触发双击事件时,取消单击事件的执行
 } else {
    
    
  // 单击事件延时300毫秒执行
   _this.lastTapTimeoutFunc = setTimeout(function() {
    
    
   	console.log("单击")
   //_this.handleVideo('playOrStop',index)自定义事件
   	}, 300);
 } 			
}
}

Guess you like

Origin blog.csdn.net/yuwenwenwenwenyu/article/details/113373886