diff --git a/src/guide/migration/async-components.md b/src/guide/migration/async-components.md index b9fa2fee1e..f9032ad105 100644 --- a/src/guide/migration/async-components.md +++ b/src/guide/migration/async-components.md @@ -20,14 +20,14 @@ For a more in-depth explanation, read on! Previously, async components were created by simply defining a component as a function that returned a promise, such as: ```js -const asyncPage = () => import('./NextPage.vue') +const asyncModal = () => import('./Modal.vue') ``` Or, for the more advanced component syntax with options: ```js -const asyncPage = { - component: () => import('./NextPage.vue'), +const asyncModal = { + component: () => import('./Modal.vue'), delay: 200, timeout: 3000, error: ErrorComponent, @@ -45,11 +45,11 @@ import ErrorComponent from './components/ErrorComponent.vue' import LoadingComponent from './components/LoadingComponent.vue' // Async component without options -const asyncPage = defineAsyncComponent(() => import('./NextPage.vue')) +const asyncModal = defineAsyncComponent(() => import('./Modal.vue')) // Async component with options -const asyncPageWithOptions = defineAsyncComponent({ - loader: () => import('./NextPage.vue'), +const asyncModalWithOptions = defineAsyncComponent({ + loader: () => import('./Modal.vue'), delay: 200, timeout: 3000, errorComponent: ErrorComponent, @@ -57,13 +57,17 @@ const asyncPageWithOptions = defineAsyncComponent({ }) ``` +::: tip NOTE +Vue Router supports a similar mechanism for asynchronously loading route components, known as *lazy loading*. Despite the similarities, this feature is distinct from Vue's support for async components. You should **not** use `defineAsyncComponent` when configuring route components with Vue Router. You can read more about this in the [Lazy Loading Routes](https://next.router.vuejs.org/guide/advanced/lazy-loading.html) section of the Vue Router documentation. +::: + Another change that has been made from 2.x is that the `component` option is now renamed to `loader` in order to accurately communicate that a component definition cannot be provided directly. ```js{4} import { defineAsyncComponent } from 'vue' -const asyncPageWithOptions = defineAsyncComponent({ - loader: () => import('./NextPage.vue'), +const asyncModalWithOptions = defineAsyncComponent({ + loader: () => import('./Modal.vue'), delay: 200, timeout: 3000, errorComponent: ErrorComponent,