微信小程序实例:点击事件和长按事件的代码实现
本篇文章给大家带来的内容是关于微信小程序实例:点击事件和长按事件的代码实现,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
<button bindtouchstart="handleTouchStart" bindtouchend="handleTouchEnd" bindlongpress="handleLongPress" bindtap="handleClick">点击/长按</button> <!-- button 可以换成view-->
//touch starthandleTouchStart: function(e) { this.startTime = e.timeStamp; //console.log(" startTime = " + e.timeStamp); }, //touch endhandleTouchEnd: 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 <p>