data(){return{timer:null}},
methods:{
//节流 后触发
//用法 this.throttle("getData", 1000) (方法名,延迟时间:多久内点击无效)
throttle(func, delay) {
clearTimeout(this.timer)
this.timer = null
if (!this.timer) {
this.timer = setTimeout(() => {
this[func]()
}, delay);
}
},
}
节流 后触发 vue2 uniapp
最新推荐文章于 2024-07-19 11:23:25 发布