其他分享
首页 > 其他分享> > 【踩坑记录】cascader 搜索show-search

【踩坑记录】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