小程序小记1:按钮/view点击事件和长按事件
<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("长按");
},点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦