<view class="" @click="antiShake">连续触发三秒后再执行</view>
<script>
export default {
data() {
return {
};
},
components: {
},
onLoad(option) {
},
onShow() {},
methods: {
// 防抖函数
antiShake() {
let that = this;
let timer = null;
if (timer) {
clearTimeout(that.timer);
}
timer = setTimeout(() => {
uni.showToast({
title: '三秒后执行成功',
duration: 2000
});
console.log("三秒后执行")
}, 1000 * 3);
}
}
};
</script>