let arr = [];
let child = [];
menu.forEach(function(item){
arr.push({title: item.title, index: item.index,children:item.children});
});
arr.forEach(ol=>{
ol.children.forEach(el=>{
ol.children.push({title: el.title, index: el.index,children:el.children});
});
ol.children = ol.children.filter(item => !item.Id); //过滤掉含有menuId的数据
child = ol.children;
child = child.filter(item => item.children.length>0);
child.forEach(index=>{
index.children.forEach(i=>{
index.children.push({title: i.title, index: i.index});
});
index.children = index.children.filter(item => !item.Id);
})
});
网友评论