流浪のwolf

卷帝

导航

watch 监视搜索关键词的变化不断发送请求返回建议

  watch: {
    keywords: {
      // yarn add lodash 下载lodash包
      // import { debounce } from "lodash"; 引入防抖的函数
      // 每隔700ms执行一次handler函数(在keywords变化的情况下,频繁触发的事件)
      handler: debounce(function (val) {
        // 调用建议的接口
        this.getSuggestion();
      }, 700),
    },
  },

 

posted on 2022-10-13 16:54  流浪のwolf  阅读(14)  评论(0编辑  收藏  举报