我怎样才能得到它快速与文本字段手表?



在文本字段中输入输入值作为参数。但每次我按下一个键,它的工作速度都很慢。我怎样才能加快速度呢?html代码

<v-col cols="3">
<v-text-field
v-model="registerSearch">
</v-text-field>
</v-col>

脚本代码

watch: {
async registerSearch(value){
if(value){
if(this.registerSearch.length == 10 || this.registerSearch.length == 11){
this.customer.TaxNumber=this.registerSearch;
if(this.registerSearch.length == 11){
await this.$validator.reset();

}else{
this.searched=false;
}
else{
this.Search=[]
this.customer.Company=''
this.customer.FirstName=''
this.customer.LastName=''
this.searched = false;
this.disableControl=true;
await this.$validator.reset();
}
}
}
}

可以尝试延迟搜索。用户输入几个字符后才开始搜索。下面是lodash发音的例子。

import _ from 'lodash'
methods: {
onChanged: _.debounce(function (event) {
// search method here...  
}, 300),
}

最新更新