for循环递归
function afun(list){
list.forEach(i =>{
i.path = i.menuPath
if(i.childMenuList && i.childMenuList.length){
a(i.childMenuList)
}
})
console.log(list)
}
function bfun(){
var menuList= [{“id”:“8a89b4d678de07270178e91540060045”,“parentId”:“8a89b4d678de07270178dec3e75a0015”,“code”:“1618818187260”,“name”:“应急资源管理”,“menuPath”:"",“childMenuList”:[{“id”:“8a89b4d678de07270178e917ef0f0055”,“parentId”:“8a89b4d678de07270178e91540060045”,“code”:“1618818363151”,“name”:“应急物资管理”,“menuPath”:"",“childMenuList”:[{“id”:“8a89b4d678e9eb7d0178ee187cac0017”,“parentId”:“8a89b4d678de07270178e917ef0f0055”,“code”:“1618902285484”,“name”:“机构物资储备总览”,“menuPath”:“inventoryOverviewStaff”},{“id”:“8a89b4d678e9eb7d0178ee1845170010”,“parentId”:“8a89b4d678de07270178e917ef0f0055”,“code”:“1618902271255”,“name”:“全市物资储备管理”,“menuPath”:"/inventoryOverview"},{“id”:“8a89b4d678fc7bb10178fcbe5a09000d”,“parentId”:“8a89b4d678de07270178e917ef0f0055”,“code”:“1619148036617”,“name”:“储备库物资管理”,“menuPath”:"/inventoryManage"}]},{“id”:“8a89b4d678e9eb7d0178ee181d58000a”,“parentId”:“8a89b4d678de07270178e91540060045”,“code”:“1618902261079”,“name”:“资源目录管理”,“menuPath”:"",“childMenuList”:[{“id”:“8a89b4d678e9eb7d0178ee18b6aa001d”,“parentId”:“8a89b4d678e9eb7d0178ee181d58000a”,“code”:“1618902300330”,“name”:“全局资源”,“menuPath”:"/resourceList"},{“id”:“8a89b4d678e9eb7d0178ee196dd20033”,“parentId”:“8a89b4d678e9eb7d0178ee181d58000a”,“code”:“1618902347218”,“name”:“本地资源”,“menuPath”:"/resourceListLocal"}]}]}];
afun(menuList)
}
bfun()