函数防抖 当业务功能满足以下三个条件: 1、频繁触发 2、耗时操作 3、只关心最终结果 function debounce(fn,deplay=300){ let timerId; return function(...args){ if(timerId){ clearTimeout(timerId); } timerId=setTimeout(()=>{ fn.call(this,...args); },deplay) } }