小程序点击和长按时间处理

2022-08-25  本文已影响0人  hao_developer
<image catchtap="seeImg" bindlongtap="longTap" data-index="{{index}}" bindtouchstart="bindTouchStart" bindtouchend="bindTouchEnd" mode="aspectFill" class="item-img item-common-img" src="{{item}}"></image>
data:{
 startTime: 0, //触摸删除按钮时
 endTime: 0, //触摸删除按钮后  
}
bindTouchStart(e) {
  this.data.startTime = e.timeStamp;
},
bindTouchEnd(e) {
  this.data.endTime = e.timeStamp;
},
longTap(e) {//长按事件
},
seeImg(e) {//点击事件
  const selfThis = this;
  if ((selfThis.data.endTime - selfThis.data.startTime) < 350) {
    //todo 点击事件
  }
 }
上一篇 下一篇

猜你喜欢

热点阅读