data() {
return {
routeData: [
{
path: "/index",
name: "index",
children: [
{
path: "/home",
children: [
{
path: "/index",
children: [
{
path: "/test",
children: [
{
path: "/tetststtesst",
},
],
},
],
},
],
},
{
path: "/shop",
},
],
},
{
path: "/Manager",
name: "Manager",
children: [
{
path: "/List",
},
{
path: "/keepList",
},
],
},
],
};
},
methods: {
init(array) {
array.map((item) => {
if (item.children) {
let Fpath = item.path; //父级path
let Item = item.children;
Item.map((Citem) => {
//子级path
Citem.path = Fpath + Citem.path;
if (Citem.children) {
this.deldata(Citem.children, Citem.path);
}
});
}
});
console.log("路由", this.routeData);
},
deldata(arr, path) {
arr.map((item) => {
item.path = item.path + path;
if (item.children) {
this.deldata(item.children, item.path);
}
});
},
},