vue2和vue3都明确说了
filter-method为一个Function,它会在输入值发生变化时调用,参数为当前输入值。
还有一帮帖子在讲反true、false啥的
我真傻、真的
本质上来讲,就是在filter-method中,对下拉参的源数据进行过滤,使用filter返回一个新数组作为当前的下拉参,然后赋值,实现搜索效果
filterMethodCompany(val){
if (!val) {
this.collectingCompanyCopy = this.collectingCompany;
} else {
const lowerVal = val.toLowerCase();
this.collectingCompanyCopy = this.collectingCompany.filter(item => {
const codeMatch = item.customCode.toLowerCase().includes(lowerVal);
const nameMatch = item.domesticCompanyNameCn.toLowerCase().includes(lowerVal);
return codeMatch || nameMatch;
});
}
},
在获取焦点的时候,重置未最全的下拉参数据源
companyFocus(){
this.collectingCompanyCopy = this.collectingCompany;
},
但是,这种方式总感觉很笨,不知道有没有更好的办法