function replaceChildrenWithDepartmentTree(obj: { children: any; departmentTree: any[]; }) {
if (obj.children) {
obj.departmentTree = obj.children;
delete obj.children;
obj.departmentTree.forEach((subObj: any) => replaceChildrenWithDepartmentTree(subObj));
}
}
payload.forEach((obj: any) => replaceChildrenWithDepartmentTree(obj));
多维数组的 对象数组属性进行替换
最新推荐文章于 2024-06-14 11:01:38 发布