vue-element-admin,路由中只有一个页面时,router/index.js该怎么写?
// 外部链接 {
path: '/userLinks',
name: 'userLinks',
component: '@/views/page/userLinks.vue',
meta: {
navigation: true,
title: 'userLinks',
icon: 'el-icon-link',
rules: ["admin"]
},
},
上面的写法显示不了。
改成下面的代码,能显示,但是页面不跳转
path: '/userLinks', component: Layout,
redirect: '/userLinks',
name: 'userLinks',
meta: {
navigation: true,
title: 'userLinks',
icon: 'el-icon-link',
rules: ["admin"]
},
children: [
{
path: 'userLinks',
component: () => import('@/views/page/userLinks.vue'),
name: 'userLinks',
meta: {
title: 'userLinks',
navigation: true,
noCache: true,
icon: 'el-icon-link',
}
}
]
解决了,下面代码:
// 外部链接 {
path: '/userLinks',
component: Layout,
name: 'userLinks',
//当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
redirect: '/userLinks/userLinks',
meta: {
navigation: true,
title: 'userLinks',
icon: 'el-icon-link',
rules: ["admin"]
},
disabled: false,
children: [
{
path: 'userLinks',
name: 'userLinks',
component: () => import('@/views/page/userLinks.vue'),
meta: {
// 用户链接
title: 'userLinks',
navigation: false,
icon: 'el-icon-link'
},
disabled: false
}
]
},
回答:
类以这样
{ path: '/charts',
component: Layout,
redirect: 'noRedirect',
name: 'Charts',
meta: {
title: 'Charts',
icon: 'chart'
},
children: [
{
path: 'keyboard',
component: () => import('@/views/charts/keyboard'),
name: 'KeyboardChart',
meta: { title: 'Keyboard Chart', noCache: true }
}
]
}
或者不需要公共layout
{ path: '/login',
component: () => import('@/views/login/index')
}
以上是 vue-element-admin,路由中只有一个页面时,router/index.js该怎么写? 的全部内容, 来源链接: utcz.com/p/936156.html