vue-防抖函数
throttle(fn, delay) {
let t = true
return function () {
if (t) {
setTimeout(() => {
fn.call(this)
t = true
}, delay)
}
t = false;
}
}
【勤则百弊皆除】
throttle(fn, delay) {
let t = true
return function () {
if (t) {
setTimeout(() => {
fn.call(this)
t = true
}, delay)
}
t = false;
}
}