12345678910 |
- // 防抖 https://www.30secondsofcode.org/js/s/debounce
- export default (fn: Function, ms = 0) => {
- let timeoutId: number | undefined;
- return function(...args: any[]) {
- clearTimeout(timeoutId)
- // @ts-ignore
- timeoutId = setTimeout(() => fn.apply(this, args), ms);
- }
- }
|