树查询
const filterTree = (tree) => {
if (!(tree && tree.length)) {
return [];
}
let newChildren = [];
for (let node of tree){
let subs = filterTree(node.children);
if (node.name.indexOf(keyword.value) > -1) {
newChildren.push(node);
} else if (subs && subs.length) {
node.children = subs;
newChildren.push(node);
}
}
return newChildren.length ? newChildren : [];
}