//循环修改tree Key 值
export function mapTree(org) {
const haveChildren =
Array.isArray(org.childList) && org.childList.length > 0;
return {
//分别将我们查询出来的值做出改变他的key
label: org.name,
value: org.id,
// expand: org.isParent, //父级是否默认展开
// data: { …org }, //是否生成所有
//判断它是否存在子集,若果存在就进行再次进行遍历操作,知道不存在子集便对其他的元素进行操作
children: haveChildren
? org.childList.map(i => mapTree(i))
: undefined
};
}
tree 树形递归修改 key
最新推荐文章于 2022-11-20 22:59:45 发布