UnisKB/ui/src/utils/array.ts

8 lines
235 B
TypeScript
Raw Normal View History

2025-06-24 06:49:09 +00:00
// 树形结构转平
export function TreeToFlatten(treeData: any[]) {
return treeData.reduce((acc, node) => {
const { children, ...rest } = node
return [...acc, rest, ...(children ? TreeToFlatten(children) : [])]
}, [])
}