微信小程序点击事件和长按事件

 
更多
<button 
bindtouchstart="handleTouchStart" 
bindtouchend="handleTouchEnd" 
bindlongpress="handleLongPress" 
bindtap="handleClick">
点击/长按</button> 
<!-- button 可以换成view-->

//touch start
handleTouchStart: function(e) {    
    this.startTime = e.timeStamp;    
    //console.log(" startTime = " + e.timeStamp);  
},  
 
//touch end
handleTouchEnd: function(e) {    
    this.endTime = e.timeStamp;    
    //console.log(" endTime = " + e.timeStamp);  
},  
 
handleClick: function(e) {    
    //console.log("endTime - startTime = " + (this.endTime - this.startTime));    
    if (this.endTime - this.startTime < 350) {      
    console.log("点击");    
    }  
},  
 
handleLongPress: function(e) {    
//console.log("endTime - startTime = " + (this.endTime - this.startTime));
console.log("长按");  
},
打赏

本文固定链接: https://www.cxy163.net/archives/2594 | 绝缘体

该日志由 绝缘体.. 于 2024年10月01日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: 微信小程序点击事件和长按事件 | 绝缘体
关键字: , , ,

微信小程序点击事件和长按事件:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter