动态组件有两种常用场景:
一是动态路由:
// 动态路由
export const asyncRouterMap: Array<RouteRecordRaw> = [
{
path: '/',
name: 'index',
meta: { title: '首页' },
component: BasicLayout, // 引用了 BasicLayout 组件
redirect: '/welcome',
children: [
{
path: 'welcome',
name: 'Welcome',
meta: { title: '引导页' },
component: () => import('@/views/welcome.vue')
},
...
]
}
]