1、这里子元素的标识是menuId,父id是parentId
//转化后的树形结构数据 getTree(menuList) { let menus = []; let sourceMap = {}; menuList.forEach(item => { item.children = []; sourceMap[item.menuId] = item; if (Number(item.parentId) === 0) { menus.push(item); } else { if (sourceMap[item.parentId]) { if(item.path.indexOf('developing') > -1){ item.development = false; }else{ item.development = true; } sourceMap[item.parentId].children.push(item); } } }) return menus; },
标签:development,menus,转换,树状,item,sourceMap,数组,parentId,children From: https://www.cnblogs.com/LindaBlog/p/17989219