# 防抖
防抖函数,经典的用于搜索框实时搜索,提高性能。
import { debounce } from 'util-snippets'
deepClone(fn(),time)
const throttle = (fn, interval = 300) => {
let canRun = true;
return () => {
if (!canRun) {
return;
}
canRun = false;
setTimeout(() => {
fn.apply();
canRun = true;
}, interval);
};
};