本篇文章给大家带来的内容是关于微信小程序实例:点击事件和长按事件的代码实现,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
<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("长按"); },
相关推荐:
小程序中button以及滚动条默认样式如何清除(代码)
微信小程序中json配置的配置方法介绍(附代码)
以上就是微信小程序实例:点击事件和长按事件的代码实现的详细内容,更多请关注知企PROSAAS其它相关文章!
温馨提示:
文章链接:https://www.prosaas.cn/17086.html
更新时间:2018年08月21日
声明: 本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:973664285@qq.com我们将第一时间处理! 资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。 所有资源仅限于参考和学习,版权归原作者所有,更多请阅读知企PROSAAS协议声明:本文由5201314发布,本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。