需求:
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 協議》,轉載必須註明作者和本文連結