template
<van-field
v-model="value"
/>
watch
watch: {
value() {
this.fnThrottle(this.searchAction, 300)(); // 无操作,延迟300ms后执行方法
}
}
methods
searchAction() { // 执行的函数
console.log(this.value)
},
fnThrottle (method, delay) {
var timer = this.timer;
return _=>{
var context = this;
var args = arguments;
clearTimeout(timer);
this.timer=setTimeout(_=>{
method.apply(context,args);
},delay);
}
},