```
let list = [
{
children: [
{
name: '名字01'
},
{
name: '名字02'
}
]
},
{
children: [
{
name: '名字11'
},
{
name: '名字12'
}
]
}
]
// 便利外层循环
for(let i=0;i<list.length;i++) {
if (list[i]['children']) {
list[i]['children'].forEach((item,index)=> {
item.id = index
})
}
}
console.log(list)
```