elementUI 下拉框远程搜索 输入值后间隔1s请求接口

remoteMethod(query) {
      if (this.timer) {
        clearTimeout(this.timer);
      }
      if (query !== "") {
        this.loading = true;
        this.timer = setTimeout(() => {
          this.loading = false;
          this.options = this.list.filter((item) => {
            return item.label.toLowerCase().indexOf(query.toLowerCase()) > -1;
          });
        }, 1000);
      } else {
        this.options = [];
      }
    },
remoteMethod //远程搜索方法,输入值改变后触发
添加定时器后指的是用户停止输入一秒后执行代码

原文地址:https://www.cnblogs.com/linliu/p/14822787.html