vue-element-admin 请教一个路由配置的问题。

vzgqcmou  于 5个月前  发布在  其他
关注(0)|答案(5)|浏览(64)

这是我复制的该项目代码: {
path: '/',
component: Layout,
redirect: '/dashboard',
children: [
{
path: 'dashboard',
component: () => import('@/views/dashboard/index'),
name: 'Dashboard',
meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
}
]
},
{
path: '/documentation',
component: Layout,
children: [
{
path: 'index',
component: () => import('@/views/documentation/index'),
name: 'Documentation',
meta: { title: 'Documentation', icon: 'documentation', affix: true }
}
]
},
{
path: '/guide',
component: Layout,
redirect: '/guide/index',
children: [
{
path: 'index',
component: () => import('@/views/guide/index'),
name: 'Guide',
meta: { title: 'Guide', icon: 'guide', noCache: true }
}
]
},
{
path: '/profile',
component: Layout,
redirect: '/profile/index',
hidden: true,
children: [
{
path: 'index',
component: () => import('@/views/profile/index'),
name: 'Profile',
meta: { title: 'Profile', icon: 'user', noCache: true }
}
]
}
这里有个疑惑,为什么不把这些路由都作为Layout的children,这样Layout只需要用一次就够了,不用每个route都写Layout。上面的写法是出于什么考虑吗

3htmauhk

3htmauhk1#

你可以按照你的想法试试,你就会知道原因了…

------------------ 原始邮件 ------------------ 发件人: "cool-518"<notifications@github.com>; 发送时间: 2020年6月10日(星期三) 下午3:05 收件人: "PanJiaChen/vue-element-admin"<vue-element-admin@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: [PanJiaChen/vue-element-admin] 请教一个路由配置的问题。 (#3245) 这是我复制的该项目代码: { path: '/', component: Layout, redirect: '/dashboard', children: [ { path: 'dashboard', component: () => import('@/views/dashboard/index'), name: 'Dashboard', meta: { title: 'Dashboard', icon: 'dashboard', affix: true } } ] }, { path: '/documentation', component: Layout, children: [ { path: 'index', component: () => import('@/views/documentation/index'), name: 'Documentation', meta: { title: 'Documentation', icon: 'documentation', affix: true } } ] }, { path: '/guide', component: Layout, redirect: '/guide/index', children: [ { path: 'index', component: () => import('@/views/guide/index'), name: 'Guide', meta: { title: 'Guide', icon: 'guide', noCache: true } } ] }, { path: '/profile', component: Layout, redirect: '/profile/index', hidden: true, children: [ { path: 'index', component: () => import('@/views/profile/index'), name: 'Profile', meta: { title: 'Profile', icon: 'user', noCache: true } } ] } 这里有个疑惑,为什么不把这些路由都作为Layout的children,这样Layout只需要用一次就够了,不用每个route都写Layout。上面的写法是出于什么考虑吗 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

mw3dktmi

mw3dktmi2#

@caohuiboss 我的项目里就是这么写的。没有发现什么问题。不过如果给页面切换时设置transition时显示有点问题,还不确定是不是路由配置引起的。

6yoyoihd

6yoyoihd3#

是不是路由原因你可以先去除你现在的写法,看看会不会出这个问题,然后一点点加回去,前后比较,就可以排查哪个环节出问题…

------------------ 原始邮件 ------------------ 发件人: "cool-518"<notifications@github.com>; 发送时间: 2020年6月10日(星期三) 下午3:12 收件人: "PanJiaChen/vue-element-admin"<vue-element-admin@noreply.github.com>; 抄送: "曹辉"<2550465923@qq.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [PanJiaChen/vue-element-admin] 请教一个路由配置的问题。 (#3245) @caohuiboss 我的项目里就是这么写的。没有发现什么问题。不过如果给页面切换时设置transition时显示有点问题,还不确定是不是路由配置引起的。 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

vecaoik1

vecaoik14#

@caohuiboss 如果可以不考虑transition的情况下,为什么要上面那样写,而不是只写一次

j91ykkif

j91ykkif5#

都行…

------------------ 原始邮件 ------------------ 发件人: "cool-518"<notifications@github.com>; 发送时间: 2020年6月10日(星期三) 下午3:22 收件人: "PanJiaChen/vue-element-admin"<vue-element-admin@noreply.github.com>; 抄送: "曹辉"<2550465923@qq.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [PanJiaChen/vue-element-admin] 请教一个路由配置的问题。 (#3245) @caohuiboss 如果可以不考虑transition的情况下,为什么要上面那样写,而不是只写一次 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

相关问题