JS 递归树结构数据查找所有叶子节点
export function getAllLeaf (data) {
let result = []
function getLeaf (data) {
data.forEach(item => {
if (!item.children) {
result.push(item.path)
} else {
getLeaf(item.children)
}
})
}
getLeaf(data)
return result
}