哪位大师能用匿名递归下这个无限极分类?
需求:
1、给下面的每个ID,添加一个“authority”属性,
2、authority属性 是一个字符串或者是一个数组字符串,样式如下:”authority”:[“admin”]或者:”authority”:[“admin”,”user”,”guest”]。
3、请用匿名函数递归的方式把authority属性,分别插入每个ID项。
{
“data”: [
{
“id”: 1,
“parent_id”: 0,
“parent_path”: null,
“name”: “欢迎”,
“icon”: “smile”,
“path”: “/welcome”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: [
{
“id”: 2,
“parent_id”: 1,
“parent_path”: null,
“name”: “表单”,
“icon”: “form”,
“path”: “/form”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
},
{
“id”: 3,
“parent_id”: 1,
“parent_path”: null,
“name”: “基础表单”,
“icon”: “smile”,
“path”: “/form/basic-form”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
}
]
},
{
“id”: 4,
“parent_id”: 0,
“parent_path”: null,
“name”: “列表”,
“icon”: “table”,
“path”: “/list”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: [
{
“id”: 5,
“parent_id”: 4,
“parent_path”: null,
“name”: “查询列表”,
“icon”: “smile”,
“path”: “/list/search”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
},
{
“id”: 6,
“parent_id”: 4,
“parent_path”: null,
“name”: “项目列表”,
“icon”: “smile”,
“path”: “/list/search/projects”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
}
]
},
{
“id”: 7,
“parent_id”: 0,
“parent_path”: null,
“name”: “信息”,
“icon”: “profile”,
“path”: “/profile”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: [
{
“id”: 8,
“parent_id”: 7,
“parent_path”: null,
“name”: “基本信息”,
“icon”: “profile”,
“path”: “/profile/basic”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
},
{
“id”: 9,
“parent_id”: 7,
“parent_path”: null,
“name”: “个性信息”,
“icon”: “profile”,
“path”: “/profile/advanced”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
}
]
},
{
“id”: 10,
“parent_id”: 0,
“parent_path”: null,
“name”: “调试”,
“icon”: “bug”,
“path”: “/result”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: [
{
“id”: 11,
“parent_id”: 10,
“parent_path”: null,
“name”: “结果集”,
“icon”: “CheckCircleOutlined”,
“path”: “/result/success’”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
},
{
“id”: 12,
“parent_id”: 10,
“parent_path”: null,
“name”: “错误表”,
“icon”: “warning”,
“path”: “/exception”,
“locale”: null,
“sequence”: 10000,
“hideInMenu”: 0,
“hideChildrenInMenu”: 0,
“children”: []
}
]
}
]
}
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: