<view bindtap='debounce' bindtouchstart="touchStart" bindtouchend="touchEnd">疯狂点击</view>
touchStart(e) {
this.touchStartTime = e.timeStamp;//按下按钮的瞬间
},
touchEnd(e) {
this.touchEndTime = e.timeStamp;//松开按钮的瞬间
},
debounce:function(e){
const that = this;
if (that.touchEndTime - that.touchStartTime < 350) { //防止长按触发点击事件
let currentTime = e.timeStamp; // 当前点击的时间
let lastTapTime = that.lastTapTime;// 当前点击的时间
that.lastTapTime = currentTime;// 更新最后一次点击时间
if (currentTime - lastTapTime > 300) { // 自定义频繁点击的时间,超出则为频繁点击
console.log('符合非频繁点击事件,please do something');
}
}