fix Bug or add example

This commit is contained in:
Ah jung
2021-07-21 18:33:02 +08:00
parent 54e68db0c2
commit fa8b33acbe
32 changed files with 1096 additions and 287 deletions

View File

@@ -42,3 +42,34 @@ export const withInstall = <T>(component: T, alias?: string) => {
};
return component as T & Plugin;
};
/**
* 找到对应的节点
* */
let result = null
export function getTreeItem(data: any[], key?: string | number) {
data.map(item => {
if (item.key === key) {
result = item;
} else {
if (item.children && item.children.length) {
getTreeItem(item.children, key);
}
}
});
return result
}
/**
* 找到所有节点
* */
let treeAll = []
export function getTreeAll(data: any[]) {
data.map(item => {
treeAll.push(item.key)
if (item.children && item.children.length) {
getTreeAll(item.children);
}
});
return treeAll
}