Vue-element-admin: 路由第三级点击会一直跳转404的问题求解 #nested route could not find

Created on 1 Feb 2018  ·  4Comments  ·  Source: PanJiaChen/vue-element-admin

现有的目录结构是这样子:
image

然后路由是这样子的:
image

渲染出来的菜单是这样子的(没有报错):
image

我把这段单独的代码贴出来:
export const asyncRouterMap = [
{
path: '/example',
component: Layout,
redirect: '/example/table',
name: 'Example',
meta: { title: 'example', icon: 'example' , roles: ['admin','editor']},
children: [
{
path: 'table',
name: 'Table',
component: _import('table/index'),
meta: { title: 'Table', icon: 'table', roles: ['admin'] },
redirect: 'noredirect',
children: [
{ path: 'test01', component: _import('table/test01'), name: 'test01', meta: { title: 'test01' }},
{ path: 'test02', component: _import('table/test02'), name: 'test02', meta: { title: 'test02' }},
]
},
{
path: 'tree',
name: 'Tree',
component: _import('tree/index'),
meta: { title: 'treeTable', icon: 'tree', roles: ['admin','editor'] }
}
]
}
]

但目前所遇到的问题是点击test01和test02的时候,会跳转到404页面,这个问题我参照了vue-element-admin的代码模仿了一遍之后,还是存在,不知道哪里出了问题,求助中。。。

Most helpful comment

example/table/index has no <router-view></router-view>
detail see nested-routes

All 4 comments

image

Should be path: '/example/table'

Dear 潘神,我把path改成 path:'/example/table'了,解决了会跳转404的问题👍 。
但现在还有一个问题,就是每次点击test01和test02,/table/test01.vue和/table/test02里面的内容不会显示出来,而每次刷新显示的都是/table/index.vue里面的内容。
如今的路由是:
image

example/table/index has no <router-view></router-view>
detail see nested-routes

对的,问题已解决, thanks a lot !

Was this page helpful?
0 / 5 - 0 ratings