对二级菜单进行搜索查询:
watch: { librarySearch(val) { if(val == '') { this.libraryFiles = this.libraryFilesAll }else { this.filterNode(val, this.libraryFilesAll); } }, }, methods: { // 左侧组织树查询筛选 filterNode(value,allArr) { let arr = JSON.parse(JSON.stringify(allArr)) let newA = [] arr.forEach((item,ind) => { newA[ind] = item newA[ind].children = item.children.filter(val => val.tablename.indexOf(value) != '-1') }) for(let i=newA.length; i--; i>0 ) { if(!newA[i].children || newA[i].children.length == 0) { newA.splice(i,1) } } this.libraryFiles = newA } // this.libraryFiles为左侧树数组 }