2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
- const Home = () => import(/* webpackChunkName: "home" */ './views/Home.vue')
-
- const routes = [
- {
- path: '/',
- name: 'Home',
- component: Home
- }
- ]
component: () => import('./views/Home.vue')
To define asynchronous components. In this way, the corresponding components will be dynamically loaded when the route is accessed.- const routes = [
- {
- path: '/',
- name: 'Home',
- component: () => import('./views/Home.vue')
- }
- ]
component: () => import('./views/Home.vue')
To define an asynchronous component.- const routes = [
- {
- path: '/',
- name: 'Home',
- component: () => import('./views/Home.vue')
- }
- ]
The above three methods can all achieve on-demand loading of routes. The specific method you choose depends on your personal preferences and project requirements.