Skip to content

Commit c4613f8

Browse files
authored
translate essentials/application (#299)
1 parent 8cbb1b9 commit c4613f8

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

src/guide/essentials/application.md

+27-26
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
# Creating a Vue Application
1+
# Vue アプリケーションの作成
22

3-
## The application instance
3+
## アプリケーションのインスタンス
44

5-
Every Vue application starts by creating a new **application instance** with the [`createApp`](/api/application#createapp) function:
5+
すべての Vue アプリケーションは [`createApp`](/api/application#createapp) 関数で新しい **アプリケーションのインスタンス** を作成することから始まります:
66

77
```js
88
import { createApp } from 'vue'
99

1010
const app = createApp({
11-
/* root component options */
11+
/* ルートコンポーネント オプション */
1212
})
1313
```
1414

15-
## The Root Component
15+
## ルートコンポーネント
1616

17-
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.
17+
`createApp` に渡しているオブジェクトは、実際にはコンポーネントになります。
18+
すべてのアプリには、「ルートコンポーネント」という、他のコンポーネントを子要素として保持できるものが必要です。
1819

19-
If you are using Single-File Components, we typically import the root component from another file:
20+
もし単一ファイルコンポーネントを使用しているなら、通常、ルートコンポーネントを他のファイルからインポートします:
2021

2122
```js
2223
import { createApp } from 'vue'
23-
// import the root component App from a single-file component.
24+
// ルートコンポーネントを単一ファイルコンポーネントからインポートする
2425
import App from './App.vue'
2526

2627
const app = createApp(App)
2728
```
2829

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:
30+
このガイドにある多くの例では単一コンポーネントしか必要としない一方で、実際のほとんどのアプリケーションではネスト化された、再利用性のあるコンポーネントツリーで構成されています。たとえば、TODO アプリケーションのコンポーネントツリーは次のようになります:
3031

3132
```
3233
App (root component)
@@ -39,11 +40,11 @@ App (root component)
3940
└─ TodoStatistics
4041
```
4142

42-
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.
43+
複数のコンポーネントをどのように定義し、一緒に構成するかについてはこのガイドの後のセクションで解説します。ですがその前に、ここでは単一コンポーネントの中で起きていることについて焦点を当てていきます。
4344

44-
## Mounting the App
45+
## アプリのマウント
4546

46-
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 要素、あるいはセレクター文字列が必要です:
4748

4849
```html
4950
<div id="app"></div>
@@ -53,13 +54,13 @@ An application instance won't render anything until its `.mount()` method is cal
5354
app.mount('#app')
5455
```
5556

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.
57+
アプリのルートコンポーネントのコンテンツはコンテナ要素の中でレンダリングされます。コンテナ要素自体はアプリの要素として見なされません。
5758

58-
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.
59+
この `.mount()` メソッドはすべてのアプリの設定やアセットの登録が完了した後、常に呼ばれる必要があります。また、アセット登録をするメソッドとは異なり、返り値はアプリケーションのインスタンスではなく、ルートコンポーネントインスタンスであるということに注意してください。
5960

60-
### In-DOM Root Component Template
61+
### DOM 内のルートコンポーネントテンプレート
6162

62-
When using Vue without a build step, we can write our root component's template directly inside the mount container:
63+
ビルドをしないで Vue を扱う場合、ルートコンポーネントのテンプレートをマウントコンテナ内に直接書くことができます:
6364

6465
```html
6566
<div id="app">
@@ -81,31 +82,31 @@ const app = createApp({
8182
app.mount('#app')
8283
```
8384

84-
Vue will automatically use the container's `innerHTML` as the template if the root component does not already have a `template` option.
85+
もしルートコンポーネントに `template` オプションがすでにない場合、Vue は自動的にコンテナの `innerHTML` をテンプレートとして使用します。
8586

86-
## App Configurations
87+
## アプリの設定
8788

88-
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:
89+
アプリケーションのインスタンスは、 `.config` オブジェクトを公開し、いくつかのアプリケーションレベルのオプションを設定することができます。たとえば、すべての子孫コンポーネントから発生したエラーを捕捉するアプリケーションレベルのエラーハンドラーを定義するには次のとおりです:
8990

9091
```js
9192
app.config.errorHandler = (err) => {
92-
/* handle error */
93+
/* エラーの制御 */
9394
}
9495
```
9596

96-
The application instance also provides a few methods for registering app-scoped assets. For example, registering a component:
97+
また、アプリケーションのインスタンスは、アプリ用のアセットを登録するいくつかのメソッドもいくつか用意しています。たとえば、次のようなコンポーネントの登録するメソッドがあります:
9798

9899
```js
99100
app.component('TodoDeleteButton', TodoDeleteButton)
100101
```
101102

102-
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) で確認することができます。
103104

104-
Make sure to apply all app configurations before mounting the app!
105+
アプリがマウントされる前に、アプリの設定がすべて適用されていることを確認しましょう!
105106

106-
## Multiple application instances
107+
## 複数のアプリケーションのインスタンス
107108

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 アプリケーションが共存することができ、それぞれが独自の設定やグローバルアセットを備えたスコープをもつことができます:
109110

110111
```js
111112
const app1 = createApp({
@@ -119,4 +120,4 @@ const app2 = createApp({
119120
app2.mount('#container-2')
120121
```
121122

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

Comments
 (0)