我对嵌套路由的延迟加载有问题!
这是我的父母路线:
import ChildRoutes from "app/modules/child.route”;
routes: [
{
path: '/child',
component: resolve => require(['app/modules/root'], resolve),
children: ChildRoutes
}
]
我的child.route.js
是
import ChildHome from …
import ChildContact from …
export default [
{
path: '',
name: 'childHome',
component: ChildHome
},
{
path: 'about',
name: 'childAbout',
// doesn’t work
component: resolve => require(['./components/about.vue'], resolve)
},
{
path: 'contact',
name: 'childContact',
// this one doesn’t work as well
component: ChildContact
},
...
]
当然,第一个子路由(childHome
)是自动工作的,但是之后,我得到的是空白页面,没有任何组件!如果我既不懒散地装载父母也不装载孩子,一切都会很好!
我在做什么错?
值得一提的是,我的项目使用vue 2.0
,vue-router
,vuex
和SSR
父母路线
import ChildRoutes from "app/modules/child.route”;
routes: [
...ChildRoutes,
]
child.route.js
export default [
{
path: '/child',
component: () => import ('@/app/modules/root'), <-- Just verify this path,
children: ...
}
]