toListtoList 方法将树形结构转换回扁平数组。
import { Tree } from '@movk/core'
const tree = [
{
id: 1,
pid: 0,
name: 'root',
children: [
{ id: 2, pid: 1, name: 'child 1' },
{ id: 3, pid: 1, name: 'child 2' }
]
}
]
const list = Tree.toList(tree)
/*
list 将会是:
[
{ id: 1, pid: 0, name: 'root' },
{ id: 2, pid: 1, name: 'child 1' },
{ id: 3, pid: 1, name: 'child 2' }
]
*/
toList<T extends TreeNode>(tree: T[], config?: TreeConfig): T[]
id, pid, children 键名的配置对象。