Skip to content

Commit a1b5410

Browse files
committed
docs: translate guide > instance
1 parent 4e5cd47 commit a1b5410

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/guide/instance.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Application & Component Instances
1+
# アプリケーションとコンポーネントのインスタンス
22

3-
## Creating an Application Instance
3+
## アプリケーションインスタンスの作成
44

55
全ての Vue アプリケーションは `createApp` 関数で新しい **アプリケーションインスタンス (application instance)** を作成するところから始まります:
66

@@ -10,7 +10,7 @@ const app = Vue.createApp({
1010
})
1111
```
1212

13-
The application instance is used to register 'globals' that can then be used by components within that application. We'll discuss that in detail later in the guide but as a quick example:
13+
アプリケーションインスタンスは、そのアプリケーション内のコンポーネントが使えるグローバル(コンポーネント、ディレクティブ、プラグインなど)を登録するために使われます。詳しいことはガイドの後半で説明しますが、簡単な例をあげると:
1414

1515
```js
1616
const app = Vue.createApp({})
@@ -19,7 +19,7 @@ app.directive('focus', FocusDirective)
1919
app.use(LocalePlugin)
2020
```
2121

22-
Most of the methods exposed by the application instance return that same instance, allowing for chaining:
22+
アプリケーションインスタンスが公開するほとんどのメソッドは、同じインスタンスを返すので、チェーンすることができます:
2323

2424
```js
2525
Vue.createApp({})
@@ -28,27 +28,27 @@ Vue.createApp({})
2828
.use(LocalePlugin)
2929
```
3030

31-
You can browse the full application API in the [API reference](../api/application-api.html).
31+
すべてのアプリケーション API [API リファレンス](../api/application-api.html) で閲覧できます。
3232

33-
## The Root Component
33+
## ルートコンポーネント
3434

35-
The options passed to `createApp` are used to configure the **root component**. That component is used as the starting point for rendering when we **mount** the application.
35+
`createApp` に渡されたオプションは、**ルートコンポーネント** の設定に使われます。このコンポーネントは、アプリケーションを **マウント** する際に、レンダリングの起点として使われます。
3636

37-
An application needs to be mounted into a DOM element. For example, if we want to mount a Vue application into `<div id="app"></div>`, we should pass `#app`:
37+
アプリケーションは DOM 要素にマウントする必要があります。例えば、 Vue アプリケーションを `<div id="app"></div>` にマウントしたい場合、 `#app` を渡す必要があります:
3838

3939
```js
4040
const RootComponent = {
41-
/* options */
41+
/* オプション */
4242
}
4343
const app = Vue.createApp(RootComponent)
4444
const vm = app.mount('#app')
4545
```
4646

47-
Unlike most of the application methods, `mount` does not return the application. Instead it returns the root component instance.
47+
ほとんどのアプリケーションメソッドとは異なり、 `mount` はアプリケーションを返しません。代わりにルートコンポーネントのインスタンスを返します。
4848

49-
Although not strictly associated with the [MVVM pattern](https://en.wikipedia.org/wiki/Model_View_ViewModel), Vue's design was partly inspired by it. As a convention, we often use the variable `vm` (short for ViewModel) to refer to a component instance.
49+
厳密には [MVVM パターン](https://en.wikipedia.org/wiki/Model_View_ViewModel) とは関係ないですが、 Vue の設計はその影響を受けています。慣習として、コンポーネントのインスタンスを参照するのに `vm` (ViewModel の略) という変数を使うことがよくあります。
5050

51-
While all the examples on this page only need a single component, most real applications are organized into a tree of nested, reusable components. For example, a Todo application's component tree might look like this:
51+
このページのすべての例では1つのコンポーネントしか必要としていませんが、実際の多くのアプリケーションでは再利用可能なコンポーネントを入れ子にしたツリー状に構成されています。例えば、 Todo アプリケーションのコンポーネントツリーは次のようになります:
5252

5353
```
5454
Root Component
@@ -61,13 +61,13 @@ Root Component
6161
└─ TodoListStatistics
6262
```
6363

64-
Each component will have its own component instance, `vm`. For some components, such as `TodoItem`, there will likely be multiple instances rendered at any one time. All of the component instances in this application will share the same application instance.
64+
各コンポーネントは、独自のコンポーネントインスタンス `vm` を持ちます。 `TodoItem` のような一部のコンポーネントでは、一度に複数のインスタンスがレンダリングされる可能性があります。このアプリケーションのすべてのコンポーネントインスタンスは、同じアプリケーションインスタンスを共有します。
6565

66-
We'll talk about [the component system](component-basics.html) in detail later. For now, just be aware that the root component isn't really any different from any other component. The configuration options are the same, as is the behavior of the corresponding component instance.
66+
[コンポーネントシステム](component-basics.html) について詳しくは、後で説明します。とりあえず、 ルートコンポーネントは他のコンポーネントとはなにも違いはないことを認識しておいてください。設定オプションは同じで、対応するコンポーネントインスタンスの振る舞いも同じです。
6767

68-
## Component Instance Properties
68+
## コンポーネントインスタンスのプロパティ
6969

70-
Earlier in the guide we met `data` properties. Properties defined in `data` are exposed via the component instance:
70+
このガイドでは `data` プロパティについて説明しました。 `data` で定義されたプロパティは、コンポーネントインスタンスを介して公開されます:
7171

7272
```js
7373
const app = Vue.createApp({
@@ -81,13 +81,13 @@ const vm = app.mount('#app')
8181
console.log(vm.count) // => 4
8282
```
8383

84-
There are various other component options that add user-defined properties to the component instance, such as `methods`, `props`, `computed`, `inject` and `setup`. We'll discuss each of these in depth later in the guide. All of the properties of the component instance, no matter how they are defined, will be accessible in the component's template.
84+
他にもコンポーネントインスタンスにユーザ定義のプロパティを追加する様々なコンポーネントオプション、`methods` `props` `computed` `inject``setup` などがあります。このガイドでは、それぞれについて後で詳しく説明します。コンポーネントインスタンスのすべてのプロパティは、それらがどのように定義されているかに関わらず、コンポーネントのテンプレートからアクセスできます。
8585

86-
Vue also exposes some built-in properties via the component instance, such as `$attrs` and `$emit`. These properties all have a `$` prefix to avoid conflicting with user-defined property names.
86+
Vue はコンポーネントインスタンスを介した `$attrs` `$emit` などいくつかの組み込みプロパティも公開しています。これらのプロパティは、すべて `$` プレフィックスとなっており、ユーザ定義のプロパティ名と衝突を避けるようになっています。
8787

88-
## Lifecycle Hooks
88+
## ライフサイクルフック
8989

90-
Each component instance goes through a series of initialization steps when it's created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it also runs functions called **lifecycle hooks**, giving users the opportunity to add their own code at specific stages.
90+
各コンポーネントインスタンスは、作られるときに一連の初期化ステップを通ります。例えば、データ監視の設定、テンプレートのコンパイル、DOM へのインスタンスのマウント、データ変更時の DOM 更新などが必要になります。また、ユーザが特定の段階で独自のコードを追加できるように **ライフサイクルフック** と呼ばれる関数の実行をします。
9191

9292
例えば [created](../api/options-lifecycle-hooks.html#created) フックは、インスタンスの作成後にコードを実行するために使用できます:
9393

0 commit comments

Comments
 (0)