vue+element-ui做的前端模糊查询
template模板代码:
<el-select
v-model="selectedValue"
@change="handleSelect"
filterable
placeholder="请搜索选择信号名称"
:filter-method="remoteMethod">
<el-option
v-for="item in options"
:key="item.id"
:label="item.signalName"
:value="item.seqNo">
</el-option>
</el-select>
data里面定义
signalList:[],
options: [],
selectedValue: '',
methods方法:
remoteMethod(query) {
if (query !== '') {
this.loading = true;
setTimeout(() => {
this.loading = false;
this.options = this.signalList.filter(item => {
return item.signalName.toLowerCase()
.indexOf(query.toLowerCase()) > -1;
});
}, 200);
} else {
this.options = [];
this.selectedValue = '';
}
},