小程序单击、长按事件冲突问题

  微信小程序事件触发顺序
单击 touchstart → touchend → tap
双击 touchstart → touchend → tap → touchstart → touchend → tap
长按 touchstart → longtap → touchend → tap

 

view界面

 

js界面

  bindTouchStart: function (e) {
    console.log('触摸开始')
    this.startTime = e.timeStamp;
  },
  bindTouchEnd: function (e) {
    console.log('触摸结束')
    this.endTime = e.timeStamp;
  },
  bindTap: function (e) {
    var that = this
    if (this.endTime - this.startTime < 350) {
      console.log("点击")
    }
  },
  bingLongTap: function (e) {
    var that = this
    console.log("长按");
  }

 

你可能感兴趣的:(小程序)