vue中搜素监听防止抖动的处理

watch {
    searchVal (newVal, oldVal) {
      if (this.timer) {
        clearTimeout(this.timer)
      }
      this.timer = setTimeout(() => {
        // 发送请求
        this.getList(newVal)
      }, 300)
    }
 }

你可能感兴趣的:(Vue)