Skip to content

Commit 75818f7

Browse files
committed
翻訳終わり🎉(残: URLの日本語化)
1 parent 0ff401b commit 75818f7

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

src/guide/component-basics.md

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ app.component('blog-post', {
225225
<blog-post ... @enlarge-text="postFontSize += 0.1"></blog-post>
226226
```
227227

228-
Then the child component can emit an event on itself by calling the built-in [**`$emit`** method](../api/instance-methods.html#emit), passing the name of the event:
228+
そして子コンポーネントはビルトインの [**`$emit`** メソッド](../api/instance-methods.html#emit) にイベントの名前を渡して呼び出すことで、イベントを送出することができます:
229229

230230
```html
231231
<button @click="$emit('enlarge-text')">Enlarge text</button>
232232
```
233233

234-
Thanks to the `v-on:enlarge-text="postFontSize += 0.1"` listener, the parent will receive the event and update `postFontSize` value.
234+
親コンポーネントは `v-on:enlarge-text="postFontSize += 0.1"` リスナーによって、このイベントを受け取り `postFontSize` を更新することができます。
235235

236236
<p class="codepen" data-height="300" data-theme-id="39028" data-default-tab="html,result" data-user="Vue" data-slug-hash="KKpGyrp" data-editable="true" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Component basics: emitting events">
237237
<span>See the Pen <a href="https://codepen.io/team/Vue/pen/KKpGyrp">
@@ -240,7 +240,7 @@ Thanks to the `v-on:enlarge-text="postFontSize += 0.1"` listener, the parent wil
240240
</p>
241241
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
242242

243-
We can list emitted events in the component's `emits` option.
243+
コンポーネントの `emits` オプションにより排出されたイベントをリストアップすることができます。
244244

245245
```js
246246
app.component('blog-post', {
@@ -249,29 +249,29 @@ app.component('blog-post', {
249249
})
250250
```
251251

252-
This will allow you to check all the events component emits and optionally [validate them](component-custom-events.html#validate-emitted-events)
252+
これにより、コンポーネントが排出する全てのイベントをチェックし、オプションでそれらを [検証する](component-custom-events.html#validate-emitted-events) ことができます。
253253

254-
### Emitting a Value With an Event
254+
### イベントと値を送出する
255255

256-
It's sometimes useful to emit a specific value with an event. For example, we may want the `<blog-post>` component to be in charge of how much to enlarge the text by. In those cases, we can use `$emit`'s 2nd parameter to provide this value:
256+
イベントを特定の値と一緒に送出すると便利な場合があります。例えば、テキストをどれだけ大きく表示するかを `<blog-post>` コンポーネントの責務とさせたいかもしれません。そのような場合、 `$emit` の第二引数を使ってこの値を渡すことができます:
257257

258258
```html
259259
<button @click="$emit('enlarge-text', 0.1)">Enlarge text</button>
260260
```
261261

262-
Then when we listen to the event in the parent, we can access the emitted event's value with `$event`:
262+
そして親でこのイベントを購読すると、 `$event` を用いて排出されたイベントの値にアクセスすることができます:
263263

264264
```html
265265
<blog-post ... @enlarge-text="postFontSize += $event"></blog-post>
266266
```
267267

268-
Or, if the event handler is a method:
268+
または、イベントハンドラがメソッドの場合:
269269

270270
```html
271271
<blog-post ... @enlarge-text="onEnlargeText"></blog-post>
272272
```
273273

274-
Then the value will be passed as the first parameter of that method:
274+
値はそのメソッドの第一引数として渡されます:
275275

276276
```js
277277
methods: {
@@ -281,21 +281,21 @@ methods: {
281281
}
282282
```
283283

284-
### Using `v-model` on Components
284+
### コンポーネントで `v-model` を使う
285285

286-
Custom events can also be used to create custom inputs that work with `v-model`. Remember that:
286+
カスタムイベントは `v-model` で動作するカスタム入力を作成することもできます。このことを覚えておいてください:
287287

288288
```html
289289
<input v-model="searchText" />
290290
```
291291

292-
does the same thing as:
292+
これは以下と同じことです:
293293

294294
```html
295295
<input :value="searchText" @input="searchText = $event.target.value" />
296296
```
297297

298-
When used on a component, `v-model` instead does this:
298+
コンポーネントで使用する場合、 `v-model` は代わりにこれを行います:
299299

300300
```html
301301
<custom-input
@@ -305,15 +305,15 @@ When used on a component, `v-model` instead does this:
305305
```
306306

307307
::: warning
308-
Please note we used `model-value` with kebab-case here because we are working with in-DOM template. You can find a detailed explanation on kebab-cased vs camelCased attributes in the [DOM Template Parsing Caveats](#dom-template-parsing-caveats) section
308+
ここでは in-DOM テンプレートを使用しているため、 `model-value` をケバブケースで表記していることに注意してください。ケバブケースの属性とキャメルケースの属性に関しては [DOM テンプレートの構文解析の注意点](#dom-template-parsing-caveats) の章で詳しく解説されています。
309309
:::
310310

311-
For this to actually work though, the `<input>` inside the component must:
311+
これが実際に機能するためには、テンプレート内の `<input>` は以下でなければなりません:
312312

313-
- Bind the `value` attribute to a `modelValue` prop
314-
- On `input`, emit an `update:modelValue` event with the new value
313+
- `value` 属性を `modelValue` プロパティにバインドする
314+
- `input` では、 `update:modelValue` イベントを新しい値と共に送出する
315315

316-
Here's that in action:
316+
以下のようになります:
317317

318318
```js
319319
app.component('custom-input', {
@@ -327,17 +327,17 @@ app.component('custom-input', {
327327
})
328328
```
329329

330-
Now `v-model` should work perfectly with this component:
330+
これで `v-model` はこのコンポーネントで完璧に動作します:
331331

332332
```html
333333
<custom-input v-model="searchText"></custom-input>
334334
```
335335

336-
Another way of creating the `v-model` capability within a custom component is to use the ability of `computed` properties' to define a getter and setter.
336+
カスタムコンポーネント内で `v-model` を使うもう一つの方法は `computed` プロパティを利用してゲッターとセッターを定義することです。
337337

338-
In the following example, we refactor the `custom-input` component using a computed property.
338+
以下の例では、computed プロパティを用いて `custom-input` コンポーネントをリファクタリングします。
339339

340-
Keep in mind, the `get` method should return the `modelValue` property, or whichever property is being using for binding, and the `set` method should fire off the corresponding `$emit` for that property.
340+
注意して欲しいのは、 `get` メソッドは `modelValue` 属性を返し、バインディングに使用しているプロパティがどれであるかに関わらず、 `set` メソッドはそのプロパティに対応する `$emit` を送出しなければならないということです。
341341

342342
```js
343343
app.component('custom-input', {
@@ -358,17 +358,17 @@ app.component('custom-input', {
358358
})
359359
```
360360

361-
That's all you need to know about custom component events 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 [Custom Events](component-custom-events.md).
361+
とりあえずカスタムコンポーネントイベントについてはこれで以上ですが、このページを読み終えて十分に理解できたら、後から戻ってきて [カスタムイベント](component-custom-events.md) の完全なガイドを読むことをお勧めします。
362362

363-
## Content Distribution with Slots
363+
## スロットによるコンテンツ配信
364364

365-
Just like with HTML elements, it's often useful to be able to pass content to a component, like this:
365+
HTML 要素のように、コンポーネントに要素を渡すことができると便利なことがよくあります。例えば以下の通り:
366366

367367
```html
368368
<alert-box> Something bad happened. </alert-box>
369369
```
370370

371-
Which might render something like:
371+
これは以下のように描画されるでしょう。:
372372

373373
<p class="codepen" data-height="300" data-theme-id="39028" data-default-tab="result" data-user="Vue" data-slug-hash="jOPeaob" data-editable="true" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Component basics: slots">
374374
<span>See the Pen <a href="https://codepen.io/team/Vue/pen/jOPeaob">
@@ -377,7 +377,7 @@ Which might render something like:
377377
</p>
378378
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
379379

380-
Fortunately, this task is made very simple by Vue's custom `<slot>` element:
380+
幸いにも、この作業は Vue のカスタム `<slot>` 要素により非常に簡単になります:
381381

382382
```js
383383
app.component('alert-box', {
@@ -390,13 +390,13 @@ app.component('alert-box', {
390390
})
391391
```
392392

393-
As you'll see above, we just add the slot where we want it to go -- and that's it. We're done!
393+
上で見た通り、ただ渡したいところにスロットを追加するだけです。それだけです。終わりです!
394394

395-
That's all you need to know about slots 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 [Slots](component-slots.md).
395+
とりあえずスロットについてはこれで以上ですが、このページを読み終えて十分に理解できたら、後から戻ってきて [スロット](component-slots.md) の完全なガイドを読むことをお勧めします。
396396

397-
## Dynamic Components
397+
## 動的なコンポーネント
398398

399-
Sometimes, it's useful to dynamically switch between components, like in a tabbed interface:
399+
タブ付きのインターフェースのように、コンポーネント間を動的に切り替えると便利なことがあります:
400400

401401
<p class="codepen" data-height="300" data-theme-id="39028" data-default-tab="result" data-user="Vue" data-slug-hash="oNXaoKy" data-editable="true" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Component basics: dynamic components">
402402
<span>See the Pen <a href="https://codepen.io/team/Vue/pen/oNXaoKy">
@@ -405,37 +405,37 @@ Sometimes, it's useful to dynamically switch between components, like in a tabbe
405405
</p>
406406
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
407407

408-
The above is made possible by Vue's `<component>` element with the `is` special attribute:
408+
上記は Vue`<component>` 属性に特別な属性である `is` を持たせることで実現しています:
409409

410410
```html
411-
<!-- Component changes when currentTabComponent changes -->
411+
<!-- コンポーネントは currentTabComponent に変更があったときに変更されます -->
412412
<component :is="currentTabComponent"></component>
413413
```
414414

415-
In the example above, `currentTabComponent` can contain either:
415+
上記の例では、 `currentTabComponent` は以下のいずれかを含むことができます:
416416

417-
- the name of a registered component, or
418-
- a component's options object
417+
- 登録されたコンポーネントの名前、または
418+
- コンポーネントのオプションオブジェクト
419419

420-
See [this sandbox](https://codepen.io/team/Vue/pen/oNXaoKy) to experiment with the full code, or [this version](https://codepen.io/team/Vue/pen/oNXapXM) for an example binding to a component's options object, instead of its registered name.
420+
完全なコードを試すには [この例](https://codepen.io/team/Vue/pen/oNXaoKy)、登録された名前ではなくコンポーネントのオプションオブジェクトをバインドしている例は [こちらのバージョン](https://codepen.io/team/Vue/pen/oNXapXM) を参照してください。
421421

422-
Keep in mind that this attribute can be used with regular HTML elements, however they will be treated as components, which means all attributes **will be bound as DOM attributes**. For some properties such as `value` to work as you would expect, you will need to bind them using the [`.prop` modifier](../api/directives.html#v-bind).
422+
この属性は通常の HTML 要素で使用することができますが、それらはコンポーネントとして扱われ、すべての属性は **DOM 属性としてバインドされる**ことを覚えておいてください。 `value` のようないくつかのプロパティが期待通りに動作するためには、 [`.prop` 修飾子](../api/directives.html#v-bind) を用いてバインドする必要があります。
423423

424-
That's all you need to know about dynamic components 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 [Dynamic & Async Components](./component-dynamic-async.html).
424+
とりあえず動的なコンポーネントについてはこれで以上ですが、このページを読み終えて十分に理解できたら、後から戻ってきて [動的 & 非同期コンポーネント](./component-dynamic-async.html) の完全なガイドを読むことをお勧めします。
425425

426-
## DOM Template Parsing Caveats
426+
## DOM テンプレートパース時の警告
427427

428-
Some HTML elements, such as `<ul>`, `<ol>`, `<table>` and `<select>` have restrictions on what elements can appear inside them, and some elements such as `<li>`, `<tr>`, and `<option>` can only appear inside certain other elements.
428+
`<ul>``<ol>``<table>` `<select>` のようないくつかの HTML 属性にはその内側でどの要素が現れるかに制限があり、`<li>``<tr>` `<option>` のようないくつかの属性は他の特定の要素の中にしか現れません。
429429

430-
This will lead to issues when using components with elements that have such restrictions. For example:
430+
このような制限を持つ属性を含むコンポーネントを使用すると問題が発生することがあります。例えば:
431431

432432
```html
433433
<table>
434434
<blog-post-row></blog-post-row>
435435
</table>
436436
```
437437

438-
The custom component `<blog-post-row>` will be hoisted out as invalid content, causing errors in the eventual rendered output. Fortunately, we can use `v-is` special directive as a workaround:
438+
このカスタムコンポート `<blog-post-row>` は無効なコンテンツとして摘み出され、最終的に描画された内容にエラーが発生します。幸い、これを回避するために `v-is` という特殊なディレクティブを使用することができます:
439439

440440
```html
441441
<table>
@@ -444,22 +444,22 @@ The custom component `<blog-post-row>` will be hoisted out as invalid content, c
444444
```
445445

446446
:::warning
447-
`v-is` value should be a JavaScript string literal:
447+
`v-is` の値は JavaScript の文字列リテラルである必要があります:
448448

449449
```html
450-
<!-- Incorrect, nothing will be rendered -->
450+
<!-- 間違い、何も出力されません-->
451451
<tr v-is="blog-post-row"></tr>
452452

453-
<!-- Correct -->
453+
<!-- 正解 -->
454454
<tr v-is="'blog-post-row'"></tr>
455455
```
456456

457457
:::
458458

459-
Also, HTML attribute names are case-insensitive, so browsers will interpret any uppercase characters as lowercase. That means when you’re using in-DOM templates, camelCased prop names and event handler parameters need to use their kebab-cased (hyphen-delimited) equivalents:
459+
また、 HTML の属性名は大文字小文字を区別しないので、ブラウザは全ての大文字を小文字として解釈します。つまり、 in-DOM テンプレートを使用している場合、キャメルケースのプロパティ名やイベントハンドラのパラメータはそれと同等のケバブケース(ハイフンで区切られた記法)を使用する必要があります:
460460

461461
```js
462-
// camelCase in JavaScript
462+
// JavaScript ではキャメルケース
463463

464464
app.component('blog-post', {
465465
props: ['postTitle'],
@@ -470,17 +470,17 @@ app.component('blog-post', {
470470
```
471471

472472
```html
473-
<!-- kebab-case in HTML -->
473+
<!-- HTML ではケバブケース -->
474474

475475
<blog-post post-title="hello!"></blog-post>
476476
```
477477

478-
It should be noted that **these limitations does _not_ apply if you are using string templates from one of the following sources**:
478+
**これらの制限は次のソースのいずれかの文字列テンプレートを使用している場合 _適用されない_ ことに**気をつけてください:
479479

480-
- String templates (e.g. `template: '...'`)
481-
- [Single-file (`.vue`) components](single-file-component.html)
480+
- 文字列テンプレート (例: `template: '...'`)
481+
- [単一ファイル (`.vue`) コンポーネント](single-file-component.html)
482482
- `<script type="text/x-template">`
483483

484-
That's all you need to know about DOM template parsing caveats for now - and actually, the end of Vue's _Essentials_. Congratulations! There's still more to learn, but first, we recommend taking a break to play with Vue yourself and build something fun.
484+
とりあえず DOM テンプレートパース時の警告についてはこれで以上です。そして実は、Vue_本質_ の最後となります。おめでとうございます! まだまだ学ぶべきことはありますが、まずは一休みして自分で Vue で遊んで楽しいものを作ってみることをお勧めします。
485485

486-
Once you feel comfortable with the knowledge you've just digested, we recommend coming back to read the full guide on [Dynamic & Async Components](component-dynamic-async.html), as well as the other pages in the Components In-Depth section of the sidebar.
486+
理解したばかりの知識に慣れてきたら、サイドバーのコンポーネントの詳細セクションの他のページと同様に、[動的 & 非同期コンポーネント](component-dynamic-async.html)の完全なガイドを読むために戻ってくることをお勧めします。

0 commit comments

Comments
 (0)