npm i lodash -S 先安装轮子
然后在需要的页面 导入他
let _ = require("lodash");
现在methods定义防抖方法
decodenameSearch: _.debounce(function(decodename) {
this.fetch(decodename);
}, 500)
然后监听watch使用
watch: {
decodename: function(val) {
this.decodenameSearch(val);
}
}
轮子真好用!