每0.5s请求一次服务器
<el-input placeholder="请输入教师姓名..." v-model="input" clearable @input="searchFn">
</el-input>
<script>
//可以放入项目中的公共方法中进行调用
function debounce(func, wait=500){
let timeout;
return function(event){
clearTimeout(timeout)
timeout = setTimeout(()=>{
func.call(this, event)
},wait)
}
}
export default{
methods:{
searchFn:debounce(function(e){
this.getTeacherList()
this.addKeyword(this.input)
this.refreshKeyword()
}),
showFn(){
console.log("222")
}
}
}
</script>
网友评论