标签:parentId 处理 children UNC == dex === code 树形结构
const treeFn = (arr) => {
const lsArr = arr.filter(i => i.parentId === ‘0‘)
function treeFnChild(fArr) {
let children = []
fArr.forEach((e, eIndex) => {
arr.forEach(i => {
if (i.parentId === e.folderId) {
children.push(i)
}
})
fArr[eIndex][‘children‘] = children
treeFnChild(children)
children = []
})
return fArr
}
}
标签:parentId 处理 children UNC == dex === code 树形结构
原文地址:https://www.cnblogs.com/Huskie-/p/14867939.html