Skip to content

Migration Guide > Async Components の翻訳 #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/guide/migration/async-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ badges:
- new
---

# Async Components <MigrationBadges :badges="$frontmatter.badges" />
# 非同期コンポーネント <MigrationBadges :badges="$frontmatter.badges" />

## Overview
## 概要

Here is a high level overview of what has changed:
こちらが大まかな変更の概要です:

- New `defineAsyncComponent` helper method that explicitly defines async components
- `component` option renamed to `loader`
- Loader function does not inherently receive `resolve` and `reject` arguments and must return a Promise
- 明示的に非同期コンポーネントを定義する、新しい `defineAsyncComponent` ヘルパーメソッド
- `component` オプションは `loader` に名前が替わりました
- loader 関数は本質的に `resolve` `reject` を引数にとらず、必ず Promise を返却します

For a more in-depth explanation, read on!
さらに詳しい説明のために読み進めましょう!

## Introduction
## イントロダクション

Previously, async components were created by simply defining a component as a function that returned a promise, such as:
以前、非同期コンポーネントは Promise を返す関数としてコンポーネントを定義することで、このように簡単に作成されました:

```js
const asyncPage = () => import('./NextPage.vue')
```

Or, for the more advanced component syntax with options:
または、オプション付きのさらに高度なコンポーネント構文として:

```js
const asyncPage = {
Expand All @@ -35,19 +35,19 @@ const asyncPage = {
}
```

## 3.x Syntax
## 3.x での構文

Now, in Vue 3, since functional components are defined as pure functions, async components definitions need to be explicitly defined by wrapping it in a new `defineAsyncComponent` helper:
現在、Vue 3 では、関数型コンポーネントは純粋関数として定義されるので、非同期コンポーネントは新しい `defineAsyncComponent` ヘルパーでラップして定義する必要があります:

```js
import { defineAsyncComponent } from 'vue'
import ErrorComponent from './components/ErrorComponent.vue'
import LoadingComponent from './components/LoadingComponent.vue'

// Async component without options
// オプションなしの非同期コンポーネント
const asyncPage = defineAsyncComponent(() => import('./NextPage.vue'))

// Async component with options
// オプション付きの非同期コンポーネント
const asyncPageWithOptions = defineAsyncComponent({
loader: () => import('./NextPage.vue'),
delay: 200,
Expand All @@ -57,7 +57,7 @@ const asyncPageWithOptions = defineAsyncComponent({
})
```

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.
2.x からなされたもう一つの変更は、直接コンポーネント定義を提供できないことを正確に伝えるために `component` オプションの名前が `loader` に替わったことです。

```js{4}
import { defineAsyncComponent } from 'vue'
Expand All @@ -71,7 +71,7 @@ const asyncPageWithOptions = defineAsyncComponent({
})
```

In addition, unlike 2.x, the loader function no longer receives the `resolve` and `reject` arguments and must always return a Promise.
加えて、2.x とは異なり、loader 関数はもう `resolve` `reject` を引数にとらず、常に Promise を返します。

```js
// 2.x version
Expand All @@ -88,6 +88,6 @@ const asyncComponent = defineAsyncComponent(
)
```

For more information on the usage of async components, see:
非同期コンポーネントの使い方のさらなる情報は、以下を見てください:

- [Guide: Dynamic & Async Components](/guide/component-dynamic-async.html#dynamic-components-with-keep-alive)
- [ガイド: 動的 & 非同期コンポーネント](/guide/component-dynamic-async.html#動的コンポーネントにおける-keep-alive-の利用)