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

    xiaoxiao2022-07-04  104

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

     

    view界面

    <view bindtouchstart="bindTouchStart" bindtouchend="bindTouchEnd" bindlongtap="bingLongTap" bindtap="bindTap">

    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("长按"); }

     

    最新回复(0)