数据准备前提:每一个子对象里有一个key是父对象的key
const temObj = {
h1: {
perent: ‘ h0’,
name: " 总监 "
},
h2:{
perent: "h1",
name:"xxx"
},
h3: {
perent:"h2",
name:"xx"
}
}
for(const key in temObj){
const resultTree = {}
const present = temObj[ key ]
If(!present) {
resultTree =
}else {
}
}
2.外层不包含key的数组对象