Dynamic imports — code splitting.
Basic:
1const routes = [2 {3 path: "/dashboard",4 component: () => import("./Dashboard.vue")5 },6 {7 path: "/settings",8 component: () => import("./Settings.vue")9 }10]
With loading:
1const Dashboard = defineAsyncComponent({2 loader: () => import("./Dashboard.vue"),3 loadingComponent: LoadingSpinner,4 delay: 2005})
Key: () => import() for lazy routes.