Do not use the @input event of EL-input, use this event, use buffering does not work. The actual code is as follows:
<template>
<el-input suffix-icon="el-icon-search" v-model="page.searchCode" clearable></el-input>
</template>
<script>
data() {
return {
timer: '',
page:{
searchCode:''
}
}
},
watch: {
'page.searchCode': {
deep: true,
handler(newVal, oldVal) {
// if (newVal.trim().length !== 0) {
//this.getList is a method called after a delay of 500ms.
this.debounce(this.getList, 500)
// }
}
}
},
methods: {
debounce(fn, wait) {
if (this.timer !== null) {
clearTimeout(this.timer)
}
this.timer = setTimeout(fn, wait)
}
},
getList(){}//The request can be written in here.
}
</script>