getMenus() {
this.$store.dispatch("user/GenerateRoutes").then((menus) => {
if (menus.length > 0) {
this.options2 = this.getChildrenMenus(menus);
}
});
},
getChildrenMenus(children) {
let itemArr = [];
for (var i = 0; i < children.length; i++) {
let item = {};
item.value = children[i].name;
item.label = children[i].meta.title;
if (typeof children[i].children != "undefined") {
item.children = this.getChildrenMenus(children[i].children);
}
itemArr.push(item);
}
return itemArr;
},
//源数据
{
"data": [
{
"name": "System",
"path": "/system",
"hidden": false,
"redirect": "noRedirect",
"component": "Layout",
"alwaysShow": true,
"meta": {
"title": "系统管理",
"icon": "system",
"noCache": false,
"link": null
},
"children": [
{
"name": "Log",
"path": "log",
"hidden": false,
"redirect": "noRedirect",
"component": "ParentView",
"alwaysShow": true,
"meta": {
"title": "日志管理",
"icon": "log",
"noCache": false,
"link": null
},
"children": [
{
"name": "Operlog",
"path": "operlog",
"hidden": false,
"component": "monitor/operlog/index",
"meta": {
"title": "操作日志",
"icon": "form",
"noCache": false,
"link": null
}
},
{
"name": "Logininfor",
"path": "logininfor",
"hidden": false,
"component": "monitor/logininfor/index",
"meta": {
"title": "登录日志",
"icon": "logininfor",
"noCache": false,
"link": null
}
}
]
}
]
},
{
"name": "Test",
"path": "/test",
"hidden": false,
"component": "Layout",
"meta": {
"title": "测试目录",
"icon": "build",
"noCache": false,
"link": null
}
}
]
}