赞
踩
const router = new Router({ routes: [{ path: "/login/index", component: () => import("../components/page/login/index.vue"), meta: { title: "登录", keepAlive: true } }, { path: "/", redirect: "/index", component: () => import("../components/page/index/index.vue"), meta: { title: "php平台开发" }, children: [{ path: "/index", component: () => import("../components/page/index/index.vue"), name: "Home", meta: { title: "首页", keepAlive: true } }] } ] });
localStorage.setItem('adminRoutes', JSON.stringify(adminRoutes)); //adminRoutes是从登陆接口成功返回的路由菜单tree数据
let adminRoutes = JSON.parse(localStorage.getItem('adminRoutes1')); let route_data = [{ path: "/login/index", component: () => import("../components/page/login/index.vue"), meta: { title: "登录", keepAlive: true } }, { path: "/", redirect: "/index", component: () => import("../components/page/index/index.vue"), meta: { title: "广告投放平台" }, children: [{ path: "/index", component: () => import("../components/page/index/index.vue"), name: "Home", meta: { title: "首页", keepAlive: true } }] }]; if(adminRoutes){ adminRoutes.forEach(function (item, index) { let menu = item; let child_data = []; item.menu.forEach(function (item, index) { let children = item.children; children.forEach(function (item,index){ let child_item = { path:item.path, redirect:item.redirect, component:() => import(`${item.component}`), meta: { title: "item.title", keepAlive: true, activeMenu: item.path } }; child_data.push(child_item) }); }); let topMenuRoute = { path:item.rPath, redirect:item.redirect, component:() => import(`${item.component}`), children:child_data }; route_data.push(topMenuRoute) }) }
item1.component = '/user/index'; let child_item = { path:item1.path, component: () => import(`../components/page/system${item1.component}.vue`), meta: { title: `${item1.title}`, keepAlive: true, } }; //如上拼接写法没问题 item1.component = '/user/index/system'; let child_item = { path:item1.path, component: () => import(`../components/page${item1.component}.vue`), meta: { title: `${item1.title}`, keepAlive: true, } }; //这种写法就会出问题,不知道问题在哪,神奇
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。