后端返回的树形不是我想要的属性,需要前端处理:
后端返回的示例:
代码:
const mapTree = org => {
const haveChildren = Array.isArray(org.childList) && org.childList.length > 0;
return {
key : org.id,
value : String(org.id),
title: org.deptName,
children:haveChildren ? org.childList.map(i => mapTree(i)) : [],
}
};
let arr = []
arr = treeData.map(org => mapTree(org) )
console.log(arr,'arr....')