tree数组降维(ts)
需求: 给定一个数组,将children数组降维添加到数组中,生成一个新的一维数组
interface Item {
id: number,
name: string,
age: number,
children?: any
}
type Items = Array<Item>
const arr: Items = [
{
id: 1,
name: 'zs',
age: 18
},
{
id: 2,
name: 'lisi'
原创
2021-07-29 16:26:13 ·
162 阅读 ·
0 评论