李强 2021-05-02 19:24:23 +08:00
parent 0d23cf97c1
commit 488247b34b
2 changed files with 12 additions and 8 deletions

View File

@ -56,14 +56,14 @@ export const constantRoutes = [
{ {
path: '', path: '',
component: Layout, component: Layout,
redirect: 'index', redirect: '/home/index',
children: [ children: [
{ // {
path: 'index', // path: 'index',
component: (resolve) => require(['@/views/index'], resolve), // component: (resolve) => require(['@/views/index'], resolve),
name: '首页', // name: '首页',
meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true } // meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
} // }
] ]
}, },
{ {

View File

@ -59,7 +59,11 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
} }
if (route.children != null && route.children && route.children.length) { if (route.children != null && route.children && route.children.length) {
route.children = filterAsyncRouter(route.children, route, type) route.children = filterAsyncRouter(route.children, route, type)
route.alwaysShow = true if (route.children.length === 1 && route.children[0].path === 'index') {
route.alwaysShow = false
} else {
route.alwaysShow = true
}
} else { } else {
delete route['children'] delete route['children']
delete route['redirect'] delete route['redirect']