iview-表格搜索

<Input v-model.trim="clusterVal" :search="true" enter-button class="fr mar-r16 wd-20P" @on-search="() => this.searchClustersFn(clusterVal)"/>
 
searchClustersFn(clusterVal) {
// tableData
this.newSourData = []
const search = (data, item, val) => {
return data[item] ? data[item].indexOf(val) !== -1 : false
}
const any = items => {
for (let i in items) {
if (items[i]) return true
}
return false
}
const that = this;
this.sourData.forEach((item) => {
const fields = ['name','display_name', 'ceph_version', 'idc']
if (any(fields.map(field => search(item, field, that.clusterVal)))) {
that.newSourData.push(item)
}
});
this.tableData = that.newSourData
},
原文地址:https://www.cnblogs.com/limengyao/p/11242805.html