//导航数据整理成三级架构
navsDataRecombine(data){
var navList = {};
if(_util.isArray(data)){
// 一级
navList.parent = data.filter(item=>item.levelcode=="1");
//二级
navList.parent.forEach(element => {
element.children = data.filter(each=>element.keyid === each.parentKeyid && each.levelcode === "2")
});
//三级
navList.parent.forEach(element => {
element.children.forEach(item2=>{
item2.children = data.filter(each=> item2.keyid === each.parentKeyid && each.levelcode === "3")
})
});
return navList;
}
}
实现结果: