我想在nodes这个数组可能有N层,我想在最后一层children的数组对象里面,每个对象加一些属性,如下
nodes = [
{
title: 'parent 1',
key: '100',
children: [
{
title: 'parent 1-0',
key: '1001',
children: [
{ title: 'leaf', key: '10010' },
{ title: 'leaf', key: '10011' },
{ title: 'leaf', key: '10012' }
]
},
]
}
];
目的:
nodes = [
{
title: 'parent 1',
key: '100',
children: [
{
title: 'parent 1-0',
key: '1001',
children: [
{ title: 'leaf', key: '10010',test:'aaaa '},
{ title: 'leaf', key: '10011',test:'aaaa ' },
{ title: 'leaf', key: '10012',test:'aaaa '}
]
},
]
}
];
这样行吗?