有一下树形数据:
const data= [
{
label: 'Level one 1',
children: [
{
label: 'Level two 1-1',
children: [
{
label: 'Level three 1-1-1',
},
],
},
],
},
{
label: 'Level one 2',
children: [
{
label: 'Level two 2-1',
children: [
{
label: 'Level three 2-1-1',
},
],
},
],
}
]
期望输出所有叶子节点的路径:
["Level one 1 > Level two 1-1 > Level three 1-1-1", "Level one 2 > Level two 2-1 > Level three 2-1-1"]
其实就是树的先序遍历