当前位置:首页站长学院后端开发微信小程序实例:点击事件和长按事件的代码实现
企业营销,就选知企PROSAAS

微信小程序实例:点击事件和长按事件的代码实现

本篇文章给大家带来的内容是关于微信小程序实例:点击事件和长按事件的代码实现,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

<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://ceshi.prosaas.cn/17086.html

更新时间:2018年08月21日

声明: 本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:973664285@qq.com我们将第一时间处理! 资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。 所有资源仅限于参考和学习,版权归原作者所有,更多请阅读知企PROSAAS协议

给TA打赏
共{{data.count}}人
人已打赏
后端开发

小程序中授权相册的解决办法(附代码)

2018-8-21 17:09:55

后端开发

小程序实例:小程序客服发送图片信息的实现代码

2018-8-21 17:19:36

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索