📌  相关文章
📜  debounce="300" - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:13.985000             🧑  作者: Mango

代码示例1
function debounce_leading(func, timeout = 300){
  let timer;
  return (...args) => {
    if (!timer) {
      func.apply(this, args);
    }
    clearTimeout(timer);
    timer = setTimeout(() => {
      timer = undefined;
    }, timeout);
  };
}