内容纲要
// 概念:回城被打断
let debounce = (fn, time, asThis) => {
let timer = null;
return (...args) => {
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
fn.call(asThis, ...args)
timer = null
}, time)
}
}
const cp = debounce(() => {
console.log('调用成功');
}, 4000);