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 object we are passing into `createApp` is in fact a component. Every app requires a "root component" that can contain other components as its children.
//import the root component App from a single-file component.
24
+
//ルートコンポーネントを単一ファイルコンポーネントからインポートする
24
25
importAppfrom'./App.vue'
25
26
26
27
constapp=createApp(App)
27
28
```
28
29
29
-
While many examples in this guide 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:
We will discuss how to define and compose multiple components together in later sections of the guide. Before that, we will focus on what happens inside a single component.
An application instance won't render anything until its `.mount()`method is called. It expects a "container" argument, which can either be an actual DOM element or a selector string:
47
+
アプリケーションのインスタンスは `.mount()`メソッドが呼ばれるまで何もレンダリングしません。インスタンスには「コンテナ」引数という、実際の DOM 要素、あるいはセレクター文字列が必要です:
47
48
48
49
```html
49
50
<divid="app"></div>
@@ -53,13 +54,13 @@ An application instance won't render anything until its `.mount()` method is cal
53
54
app.mount('#app')
54
55
```
55
56
56
-
The content of the app's root component will be rendered inside the container element. The container element itself is not considered part of the app.
The`.mount()`method should always be called after all app configurations and asset registrations are done. Also note that its return value, unlike the asset registration methods, is the root component instance instead of the application instance.
The application instance exposes a `.config`object that allows us to configure a few app-level options, for example defining an app-level error handler that captures errors from all descendent components:
This makes the `TodoDeleteButton`available for use anywhere in our app. We will discuss registration for components and other types of assets in later sections of the guide. You can also browse the full list of application instance APIs in its [API reference](/api/application).
103
+
このメソッドは、`TodoDeleteButton`をこのアプリケーション内でならどこでも使用できるようにしてくれます。コンポーネントや他のアセットの登録のやり方についてはこのガイドの後のセクションで説明します。アプリケーションのインスタンス API の全リストについては、[API reference](/api/application) で確認することができます。
103
104
104
-
Make sure to apply all app configurations before mounting the app!
105
+
アプリがマウントされる前に、アプリの設定がすべて適用されていることを確認しましょう!
105
106
106
-
## Multiple application instances
107
+
## 複数のアプリケーションのインスタンス
107
108
108
-
You are not limited to a single application instance on the same page. The `createApp` API allows multiple Vue applications to co-exist on the same page, each with its own scope for configuration and global assets:
109
+
同じページにアプリケーションのインスタンスが 1 つに制限されるわけではありません。 `createApp` API は同じページ内で複数の Vue アプリケーションが共存することができ、それぞれが独自の設定やグローバルアセットを備えたスコープをもつことができます:
109
110
110
111
```js
111
112
constapp1=createApp({
@@ -119,4 +120,4 @@ const app2 = createApp({
119
120
app2.mount('#container-2')
120
121
```
121
122
122
-
If you are using Vue to enhance server-rendered HTML and only need Vue to control specific parts of a large page, avoid mounting a single Vue application instance on the entire page. Instead, create multiple small application instances and mount them on the elements they are responsible for.
123
+
もし Vue をサーバーレンダリングされた HTML を拡張するために使用していたり、大きなページの中で特定の一部を操作するためだけに必要とするなら、ページ全体で単一の Vue アプリケーションのインスタンスでマウントするのを避けましょう。その代わりに、複数の小さなアプリケーションのインスタンスを作成し、それぞれの受け持つ要素の上でマウントするようにしてください。
0 commit comments