let dataList = [
{
id: 148
pid: 0
name: "将军"
checked: true,
child: [
{
id: 154
pid: 148
name: "师长"
checked: true
child: [
{id: 182, pid: 154,name: "营长1", checked: true, level: 2, has: false},
{id: 210, pid: 154,name: "营长2", checked: true, level: 2, has: false}
]
level: 1
has: false
}
]
level: 0
has: false
}
]
上面这个数据对象如何变成下面这种,记住每一个index自己索引的同时,还要记住他的上一级索引
let dataList = [
{
id: 148
pid: 0
name: "将军"
checked: true,
index: [0]
child: [
{
id: 154
pid: 148
name: "师长"
checked: true
child: [
{id: 182, pid: 154,name: "营长1", checked: true, level: 2, has: false,index: [0,0,0]},
{id: 210, pid: 154,name: "营长2", checked: true, level: 2, has: false,index: [0,0,1]}
]
level: 1
has: false,
index: [0,0]
}
]
level: 0
has: false
}
]
递归