|
导读微信小程序,简称小程序,英文名Mini Program,是一种不需要下载安装即可使用的应用,它实现了应用“触手可及”的梦想,用户扫一扫或搜一下即可打开应用。小程序是一种不用下载就能使用的应用,也是一... 微信小程序,简称小程序,英文名Mini Program,是一种不需要下载安装即可使用的应用,它实现了应用“触手可及”的梦想,用户扫一扫或搜一下即可打开应用。小程序是一种不用下载就能使用的应用,也是一项门槛非常高的创新,经过将近两年的发展,已经构造了新的小程序开发环境和开发者生态。 本篇文章给大家带来的内容是关于微信小程序实例:点击事件和长按事件的代码实现,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。<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("长按");
},相关推荐: 以上就是微信小程序实例:点击事件和长按事件的代码实现的详细内容,更多请关注php中文网其它相关文章! 小程序是一种不需要下载安装即可使用的应用,它实现了应用“触手可及”的梦想,用户扫一扫或者搜一下即可打开应用。 |
温馨提示:喜欢本站的话,请收藏一下本站!