【发布时间】:2023-04-03 10:56:01
【问题描述】:
我在延迟加载嵌套路由时遇到问题!
这是我的父路线:
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
【问题讨论】:
-
任何控制台错误?
-
没什么贝尔明!一个干净的控制台,正如我所说,没有组件呈现到页面中
标签: lazy-loading vue.js vue-router vuex