搜索框防抖

定义timeout初值为null

debounce(cb, wait = 500) {
  if (this.timeout !== null) {
    clearTimeout(this.timeout);
  }
  this.timeout = setTimeout(() => {
    this.timeout = null;
    cb && cb();
  }, wait);
},
posted @ 2025-04-25 10:15  双城孙宇  阅读(22)  评论(0)    收藏  举报