为了账号安全,请及时绑定邮箱和手机立即绑定

每次都会调用去抖功能

每次都会调用去抖功能

缥缈止盈 2021-05-10 01:09:05
我在keyUp上调用searchkeyword函数。我想在快速键入新字母时取消/ clearTimeout $ emit,以便只调用几次$ emit。但是控制台会在每次搜索关键字调用时被调用/反跳。  methods: {    searchKeyword : function() {      var scope = this;      (this.debounce(function(){        scope.$emit("search-keyword", scope.keyword);        console.log("Called");      },350))();    },    debounce: function (func, delay) {        var timeout;        return function() {          const context = this;          const args = arguments;          clearTimeout(timeout);          timeout = setTimeout(() => func.apply(context, args), delay);        }      }    }
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 153 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信