el-select定义搜索方法:filter-method="handleFilterSelect",输入时获得输入的内容,当调用搜索方法时再调用el-tree中定义的filter-node-method
方法,搜索出需要的内容
<el-select ref="selectTree" v-model="formInfo.name" placeholder="请选择" style="width: 100%;" filterable clearable :filter-method="handleFilterSelect">
<el-option style="height: 100%;padding: 0;" value="">
<el-tree
ref="selectTree2"
:data="itemInfo"
:props="treeProps"
:expand-on-click-node="expandOnClickNode"
:filter-node-method="filterNode"
highlight-current
default-expand-all
style="font-weight: normal;"
@node-click="handleNodeClick"
/>
</el-option>
</el-select>
js:
handleFilterSelect(val) {
this.$refs.selectTree2.filter(val)
},
filterNode(value, itemInfo) {
if (!value) return true
return itemInfo.label.indexOf(value) !== -1
// return itemInfo.label === value
},