需求是将扁平化的数组转成树形结构,比如:
const a = [[1,2,3],['a','b','c'],['A','B','C']];
const res = [];
要求a数组转化成res是这个样子:
[
{
label: '1',
children:
[
{ label: 'a',
children:[
{
label:'A'
}
]
}
]
},
{
label: '2',
children:
[
{ label: 'b',
children:[
{
label:'B'
}
]
}
]
},
{
label: '3',
children:
[
{ label: 'c',
children:[
{
label:'C'
}
]
}
]
},
]
相关分类