export function renameChildKey(tree, orign_childKey, new_childKey) {
tree.forEach(item => {
if (item[orign_childKey]) {
item[new_childKey] = item[orign_childKey];
delete item[orign_childKey];
}
if (item[new_childKey] && item[new_childKey].length > 0) {
renameChildKey(item[new_childKey], orign_childKey, new_childKey);
}
})
return tree;
}
JS给树形结构一个的childkey属性重命名
![](https://img-home.csdnimg.cn/images/20240711042549.png)