【踩坑记录】cascader 搜索show-search
作者:互联网
cascader 搜索踩坑记录
<a-form-item label="所属部门" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }">
<a-cascader
:fieldNames="{ label: 'text', value: 'id', children: 'children' }"
v-decorator="['Dept']"
placeholder="请选择所属部门"
:options="deptTreeData"
change-on-select
:show-search="{filter}"
:getPopupContainer="(triggerNode) => triggerNode.parentNode"
/>
</a-form-item>
//所属部门搜索
filter(inputValue, path) {
console.log(path)
return path.some(option => option.text.toLowerCase().indexOf(inputValue.toLowerCase()) > -1)
},
关键点在这里,官网用的是
但是我用了这个 :fieldNames="{ label: ‘text’, value: ‘id’, children: ‘children’ }",所以label因该换成
text,完美解决!
标签:search,option,show,text,label,cascader,path,toLowerCase 来源: https://blog.csdn.net/SSophia/article/details/121100264