微信小程式點選事件和長按事件
阿新 • • 發佈:2019-01-24
<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("長按"); },
個人微訊號 qicong88 ,歡迎來聊