路由懒加载与组件复用问题

组件复用问题

路由懒加载

在你具体去哪个路由的时候,再加载对应组件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const router = new VueRouter({
routes: [
{
path: '/',
component: () => import('../views/Index/index.vue'),
children: [
{
path: 'home',
component: () => import('../views/Index/home.vue')
},
{
path: 'about',
component: () => import('../views/Index/about.vue')
},
{
path: 'center',
component: () => import('../views/Index/center.vue')
},
{
path: '',
redirect: '/home'
}
]
}]
})
Share
1 min. read