延迟搜索,当input输入框值变化时,延迟1秒发送请求,若期间再次输入,则清空定时器

let btnsleep;
OnSearch(e) {
    clearTimeout(this.btnsleep);

    this.btnsleep = setTimeout(() => {
      this.inspectionService.getDocNoList(e).then(
        (data: any) => {
          this.DocNoList = data;
        });
    }, 1000);
  }

发表评论