Skip to content

Commit 99d191c

Browse files
committed
propsまで訳した
1 parent d8d6dbb commit 99d191c

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

src/guide/component-basics.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ const app = Vue.createApp({})
1212
app.component('button-counter', {
1313
data() {
1414
return {
15-
count: 0,
15+
count: 0
1616
}
1717
},
1818
template: `
1919
<button @click="count++">
2020
You clicked me {{ count }} times.
21-
</button>`,
21+
</button>`
2222
})
2323
```
2424

@@ -69,48 +69,48 @@ Components can be reused as many times as you want:
6969

7070
ボタンをクリックすると、それぞれが独自の `count` を保持することに注意してください。 これはコンポーネントを使用する度に新しいコンポーネントの**インスタンス**が作成されるためです。
7171

72-
## Organizing Components
72+
## コンポーネントの構成
7373

74-
It's common for an app to be organized into a tree of nested components:
74+
一般的にアプリケーションはネストされたコンポーネントのツリーに編成されます:
7575

76-
![Component Tree](/images/components.png)
76+
![コンポーネントツリー](/images/components.png)
7777

78-
For example, you might have components for a header, sidebar, and content area, each typically containing other components for navigation links, blog posts, etc.
78+
例えば、 ヘッダー、サイドバー、コンテンツエリアなどのコンポーネントがあり、それぞれには一般的にナビゲーションリンクやブログ投稿などのコンポーネントが含まれています。
7979

80-
To use these components in templates, they must be registered so that Vue knows about them. There are two types of component registration: **global** and **local**. So far, we've only registered components globally, using `component` method of created app:
80+
これらのコンポーネントをテンプレートで使用するためには、 Vue がそれらを認識できるように登録する必要があります。 コンポーネントの登録には **グローバル** **ローカル** の 2 種類があります。これまでは、アプリケーションの `component` メソッドを利用してグローバルに登録してきただけです:
8181

8282
```js
8383
const app = Vue.createApp({})
8484

8585
app.component('my-component-name', {
86-
// ... options ...
86+
// ... オプション ...
8787
})
8888
```
8989

90-
Globally registered components can be used in the template of `app` instance created afterwards - and even inside all subcomponents of that root instance's component tree.
90+
グローバルに登録されたコンポーネントはその後作成された `app` インスタンスのテンプレートで使用することができます。さらに、ルートインスタンスのコンポーネントツリーの全てのサブコンポーネント内でも使用することが出来ます。
9191

92-
That's all you need to know about registration for now, but once you've finished reading this page and feel comfortable with its content, we recommend coming back later to read the full guide on [Component Registration](component-registration.md).
92+
とりあえずコンポーネント登録についてはこれで以上ですが、このページを読み終えて十分に理解できたら、後から戻ってきて [コンポーネント登録](component-registration.md)の完全なガイドを読むことをお勧めします。
9393

94-
## Passing Data to Child Components with Props
94+
## プロパティを用いた子コンポーネントへのデータの受け渡し
9595

96-
Earlier, we mentioned creating a component for blog posts. The problem is, that component won't be useful unless you can pass data to it, such as the title and content of the specific post we want to display. That's where props come in.
96+
先ほど、 ブログ投稿用のコンポーネントの作成について触れました。問題は、 表示する特定の投稿のタイトルや内容のようなデータを作成したコンポーネントに渡せなければそのコンポーネントは役に立たないということです。プロパティはここで役立ちます。
9797

98-
Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance. To pass a title to our blog post component, we can include it in the list of props this component accepts, using a `props` option:
98+
プロパティはコンポーネントに登録できるカスタム属性です。値がプロパティ属性に渡されると、そのコンポーネントインスタンスのプロパティになります。先ほどのブログ投稿用のコンポーネントにタイトルを渡すためには、`props`オプションを用いてこのコンポーネントが受け取るプロパティのリストの中に含めることができます:
9999

100100
```js
101101
const app = Vue.createApp({})
102102

103103
app.component('blog-post', {
104104
props: ['title'],
105-
template: `<h4>{{ title }}</h4>`,
105+
template: `<h4>{{ title }}</h4>`
106106
})
107107

108108
app.mount('#blog-post-demo')
109109
```
110110

111-
A component can have as many props as you'd like and by default, any value can be passed to any prop. In the template above, you'll see that we can access this value on the component instance, just like with `data`.
111+
コンポーネントは必要に応じて多くのプロパティを持つことができ、デフォルトでは任意のプロパティに任意の値を渡すことができます。上記のテンプレートでは、`data` と同様に、コンポーネントインスタンスでこの値にアクセスできることが分かります。
112112

113-
Once a prop is registered, you can pass data to it as a custom attribute, like this:
113+
プロパティが登録されたら、 次のようにカスタム属性としてデータをプロパティに渡すことができます:
114114

115115
```html
116116
<div id="blog-post-demo" class="demo">
@@ -127,7 +127,7 @@ Once a prop is registered, you can pass data to it as a custom attribute, like t
127127
</p>
128128
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
129129

130-
In a typical app, however, you'll likely have an array of posts in `data`:
130+
しかしながら、一般的なアプリケーションではおそらく `data` に投稿の配列を持っています:
131131

132132
```js
133133
const App = {
@@ -136,23 +136,23 @@ const App = {
136136
posts: [
137137
{ id: 1, title: 'My journey with Vue' },
138138
{ id: 2, title: 'Blogging with Vue' },
139-
{ id: 3, title: 'Why Vue is so fun' },
140-
],
139+
{ id: 3, title: 'Why Vue is so fun' }
140+
]
141141
}
142-
},
142+
}
143143
}
144144

145145
const app = Vue.createApp(App)
146146

147147
app.component('blog-post', {
148148
props: ['title'],
149-
template: `<h4>{{ title }}</h4>`,
149+
template: `<h4>{{ title }}</h4>`
150150
})
151151

152152
app.mount('#blog-posts-demo')
153153
```
154154

155-
Then want to render a component for each one:
155+
そしてコンポーネントをそれぞれ描画します:
156156

157157
```html
158158
<div id="blog-posts-demo">
@@ -164,9 +164,9 @@ Then want to render a component for each one:
164164
</div>
165165
```
166166

167-
Above, you'll see that we can use `v-bind` to dynamically pass props. This is especially useful when you don't know the exact content you're going to render ahead of time.
167+
上記では、 `v-bind` を用いて動的にプロパティを渡すことができると分かります。これは描画する内容が事前に分からない場合に特に便利です。
168168

169-
That's all you need to know about props for now, but once you've finished reading this page and feel comfortable with its content, we recommend coming back later to read the full guide on [Props](component-props.html).
169+
とりあえずプロパティについてはこれで以上ですが、 このページを読み終えて十分に理解できたら、後から戻ってきて [プロパティ](component-props.html) の完全なガイドを読むことをお勧めします。
170170

171171
## Listening to Child Components Events
172172

@@ -181,9 +181,9 @@ const App = {
181181
posts: [
182182
/* ... */
183183
],
184-
postFontSize: 1,
184+
postFontSize: 1
185185
}
186-
},
186+
}
187187
}
188188
```
189189

@@ -209,7 +209,7 @@ app.component('blog-post', {
209209
Enlarge text
210210
</button>
211211
</div>
212-
`,
212+
`
213213
})
214214
```
215215

@@ -245,7 +245,7 @@ We can list emitted events in the component's `emits` option.
245245
```js
246246
app.component('blog-post', {
247247
props: ['title'],
248-
emits: ['enlarge-text'],
248+
emits: ['enlarge-text']
249249
})
250250
```
251251

@@ -323,7 +323,7 @@ app.component('custom-input', {
323323
:value="modelValue"
324324
@input="$emit('update:modelValue', $event.target.value)"
325325
>
326-
`,
326+
`
327327
})
328328
```
329329

@@ -352,9 +352,9 @@ app.component('custom-input', {
352352
},
353353
set(value) {
354354
this.$emit('update:modelValue', value)
355-
},
356-
},
357-
},
355+
}
356+
}
357+
}
358358
})
359359
```
360360

@@ -386,7 +386,7 @@ app.component('alert-box', {
386386
<strong>Error!</strong>
387387
<slot></slot>
388388
</div>
389-
`,
389+
`
390390
})
391391
```
392392

@@ -465,7 +465,7 @@ app.component('blog-post', {
465465
props: ['postTitle'],
466466
template: `
467467
<h3>{{ postTitle }}</h3>
468-
`,
468+
`
469469
})
470470
```
471471

0 commit comments

Comments
 (0)