微信小程序tap点击和长按冲突解决

来源:互联网 发布:软件一键位安装 编辑:程序博客网 时间:2024/05/21 04:25
  1. // wxml
  2. <view bindtouchstart="bindTouchStart" bindtouchend="bindTouchEnd" bindlongtap="bingLongTap" bindtap="bindTap"></view>
  1. // js
  2. bindTouchStart: function(e) {
  3. this.startTime = e.timeStamp;
  4. }
  5. bindTouchEnd: function(e) {
  6. this.endTime = e.timeStamp;
  7. }
  8. bindTap: function(e) {
  9. if(this.endTime - this.startTime < 350) {
  10. console.log("点击")
  11. }
  12. }
  13. bingLongTap: function(e) {
  14. console.log("长按");
  15. }
阅读全文
0 0
原创粉丝点击