防抖函数debounce报错func.apply() is not a function

136 阅读1分钟

近期在项目中需要输入框搜索功能中加一个防抖处理 从lodash库中引入debounce方法,结果控制台报错func.apply(); 更换了好几种写法都不生效,下面附上最后成功的方法;

import { debounce } from 'lodash';

search: debounce(function() {
    this.initList(this.name);
}, 200)