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

 
 
  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. }

猜你喜欢

转载自blog.csdn.net/qq_23064501/article/details/78095902