// 例子根据name字段来搜索
handleTreeData = (treeData, searchValue) => {
if (!treeData || treeData.length === 0) {
return [];
}
const array = [];
for (let i = 0; i < treeData.length; i += 1) {
if (this.handleTreeData(treeData[i].children, searchValue).length > 0 || treeData[i].name.includes(searchValue)) {
array.push({
...treeData[i],
children: this.handleTreeData(treeData[i].children, searchValue),
});
}
}
return array;
}