tree 树形结构搜索 显示子集
作者:chrispy
<el-input placeholder="搜索" v-model="filterText" style="width:calc(100% - 20px);margin:10px"></el-input>
<el-tree ref="tree" :data="treeData" node-key="id" accordion :filter-node-method="filterNode"></el-tree>
filterNode (value, data, node) { // 搜索
// 如果共有三级菜单
if (!value) return true
value = value.toLowerCase()
data = data.label.toLowerCase()
let ifOne = data.indexOf(value) !== -1
let ifTwo = node.parent && node.parent.data && node.parent.data.label && (node.parent.data.label.indexOf(value) !== -1)
let ifThree = node.parent && node.parent.parent && node.parent.parent.data && node.parent.parent.data.label && (node.parent.parent.data.label.indexOf(value) !== -1)
let resultOne = false
let resultTwo = false
let resultThree = false
if (node.level === 1) {
resultOne = ifOne
} else if (node.level === 2) {
resultTwo = ifOne || ifTwo
} else if (node.level === 3) {
resultThree = ifOne || ifTwo || ifThree
}
return resultOne || resultTwo || resultThree
},
猜你喜欢
您可能感兴趣的文章:
- PHP 是什么?
- mac 10.15 /bin/zsh zsh: fork failed: resource temporarily unavailable
- 利用lrz.bundle.js实现图片压缩上传
- php 数组 Notice: Array to string conversion
- curl或file_get_contents提示failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
- Nginx基本属性配置详解
- vue实现数组上移下移置顶置底
- Error: Record 555612 excessed the excel length limitation of cell
- element el-tree 自定义表格
- git 查看本地仓库路径
- Python Warning: Data truncated for column
- elementUI tree组件获取当前选择所有选中(check)和半选中(indeterminate)的节点
- MYSQL中TRUNCATE和DELETE的区别
- PHP json_encode 空对象和空数组处理
- mac无法将“*.zip”解压到“文件夹”。错误22 无效的参数
- 我的web前端学习之路
- 2019主流的前端框架
- 史上最全的前端学习路线图,干货满满
- javascript学习路线图