You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
You can browse the full application API in the [API reference](../api/application-api.html).
31
+
すべてのアプリケーション API は [API リファレンス](../api/application-api.html) で閲覧できます。
32
32
33
-
## The Root Component
33
+
## ルートコンポーネント
34
34
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.
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` を渡す必要があります:
38
38
39
39
```js
40
40
constRootComponent= {
41
-
/*options*/
41
+
/*オプション*/
42
42
}
43
43
constapp=Vue.createApp(RootComponent)
44
44
constvm=app.mount('#app')
45
45
```
46
46
47
-
Unlike most of the application methods, `mount`does not return the application. Instead it returns the root component instance.
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.
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 アプリケーションのコンポーネントツリーは次のようになります:
52
52
53
53
```
54
54
Root Component
@@ -61,13 +61,13 @@ Root Component
61
61
└─ TodoListStatistics
62
62
```
63
63
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.
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.
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.
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.
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 更新などが必要になります。また、ユーザが特定の段階で独自のコードを追加できるように **ライフサイクルフック** と呼ばれる関数の実行をします。
0 commit comments