@@ -20,14 +20,14 @@ badges:
2020以前、非同期コンポーネントは Promise を返す関数としてコンポーネントを定義することで、このように簡単に作成されました:
2121
2222``` js
23- const asyncPage = () => import (' ./NextPage .vue' )
23+ const asyncModal = () => import (' ./Modal .vue' )
2424```
2525
2626または、オプション付きのさらに高度なコンポーネント構文として:
2727
2828``` js
29- const asyncPage = {
30- component : () => import (' ./NextPage .vue' ),
29+ const asyncModal = {
30+ component : () => import (' ./Modal .vue' ),
3131 delay: 200 ,
3232 timeout: 3000 ,
3333 error: ErrorComponent,
@@ -45,25 +45,29 @@ import ErrorComponent from './components/ErrorComponent.vue'
4545import LoadingComponent from ' ./components/LoadingComponent.vue'
4646
4747// オプションなしの非同期コンポーネント
48- const asyncPage = defineAsyncComponent (() => import (' ./NextPage .vue' ))
48+ const asyncModal = defineAsyncComponent (() => import (' ./Modal .vue' ))
4949
5050// オプション付きの非同期コンポーネント
51- const asyncPageWithOptions = defineAsyncComponent ({
52- loader : () => import (' ./NextPage .vue' ),
51+ const asyncModalWithOptions = defineAsyncComponent ({
52+ loader : () => import (' ./Modal .vue' ),
5353 delay: 200 ,
5454 timeout: 3000 ,
5555 errorComponent: ErrorComponent,
5656 loadingComponent: LoadingComponent
5757})
5858```
5959
60+ ::: tip NOTE
61+ Vue Router は * 遅延読み込み* と呼ばれるルートコンポーネントを非同期に読み込む似たような仕組みをサポートしています。似てはいますが、この機能は Vue の非同期コンポーネントのサポートとは異なります。 Vue Router でルートコンポーネントを構成するときは、 ` defineAsyncComponent ` を ** 使用しない** 必要があります。これについては、 Vue Router のドキュメントの [ ルートの遅延読み込み] ( https://next.router.vuejs.org/guide/advanced/lazy-loading.html ) で詳しく説明されています。
62+ :::
63+
60642.x からなされたもう一つの変更は、直接コンポーネント定義を提供できないことを正確に伝えるために ` component ` オプションの名前が ` loader ` に替わったことです。
6165
6266``` js{4}
6367import { defineAsyncComponent } from 'vue'
6468
65- const asyncPageWithOptions = defineAsyncComponent({
66- loader: () => import('./NextPage .vue'),
69+ const asyncModalWithOptions = defineAsyncComponent({
70+ loader: () => import('./Modal .vue'),
6771 delay: 200,
6872 timeout: 3000,
6973 errorComponent: ErrorComponent,
0 commit comments