watch: {
filterText(val) {
console.log('val', val);
this.$refs.tree.filter(val);
}
},
methods:
// 筛选
filterNode(value, data, node) {
if (!value) return true;
let _array = []; //这里使用数组存储 只是为了存储值。
this.getReturnNode(node, _array, value);
let result = false;
_array.forEach((item) => {
result = result || item;
});
return result;
},
getReturnNode(node, _array, value) {
let isPass =
node.data && node.data.label && node.data.label.indexOf(value) !== -1;
isPass ? _array.push(isPass) : '';
if (!isPass && node.level != 1 && node.parent) {
this.getReturnNode(node.parent, _array, value);
}
},
标签:node,el,val,tree,value,result,array,data,节点
From: https://www.cnblogs.com/sinceForever/p/17867778.html