想要的格式[
[
"13",
"26b2e635-4486-45ac-8760-bb7da1e0848f",
"2f1f12e8-efa1-43c1-a3b1-f301698c32ee"
],
[
"13",
"7855f367-a156-4252-b884-75412f65abd9",
"a1f1c696-0bb6-4750-8d78-c3c8ab62f424"
]
]
使用 下面的方法即可转成上面的数据
traverse(tree, path = [], result = []) {
if (!tree) return []
for (const data of tree) {
path.push(data)
let isLeaf = !data.childs || !data.childs.length
isLeaf ? result.push([...path]) : this.traverse(data.childs, path, result)
path.pop()
}
return result
},