utils.js 210 B

12345678910
  1. // 防抖函数
  2. export const debounce = (fn, wait = 1000) => {
  3. let timer;
  4. return function (...args) {
  5. clearTimeout(timer);
  6. timer = setTimeout(() => {
  7. fn.call(this, args);
  8. }, wait);
  9. };
  10. };