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
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:
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:
When used on a component, `v-model`instead does this:
298
+
コンポーネントで使用する場合、 `v-model`は代わりにこれを行います:
299
299
300
300
```html
301
301
<custom-input
@@ -305,15 +305,15 @@ When used on a component, `v-model` instead does this:
305
305
```
306
306
307
307
::: 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
Now`v-model`should work perfectly with this component:
330
+
これで`v-model`はこのコンポーネントで完璧に動作します:
331
331
332
332
```html
333
333
<custom-inputv-model="searchText"></custom-input>
334
334
```
335
335
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.
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.
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).
As you'll see above, we just add the slot where we want it to go -- and that's it. We're done!
393
+
上で見た通り、ただ渡したいところにスロットを追加するだけです。それだけです。終わりです!
394
394
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).
In the example above, `currentTabComponent`can contain either:
415
+
上記の例では、 `currentTabComponent`は以下のいずれかを含むことができます:
416
416
417
-
-the name of a registered component, or
418
-
-a component's options object
417
+
-登録されたコンポーネントの名前、または
418
+
-コンポーネントのオプションオブジェクト
419
419
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.
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) を用いてバインドする必要があります。
423
423
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).
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>`のようないくつかの属性は他の特定の要素の中にしか現れません。
429
429
430
-
This will lead to issues when using components with elements that have such restrictions. For example:
430
+
このような制限を持つ属性を含むコンポーネントを使用すると問題が発生することがあります。例えば:
431
431
432
432
```html
433
433
<table>
434
434
<blog-post-row></blog-post-row>
435
435
</table>
436
436
```
437
437
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:
@@ -444,22 +444,22 @@ The custom component `<blog-post-row>` will be hoisted out as invalid content, c
444
444
```
445
445
446
446
:::warning
447
-
`v-is`value should be a JavaScript string literal:
447
+
`v-is`の値は JavaScript の文字列リテラルである必要があります:
448
448
449
449
```html
450
-
<!--Incorrect, nothing will be rendered -->
450
+
<!--間違い、何も出力されません-->
451
451
<trv-is="blog-post-row"></tr>
452
452
453
-
<!--Correct-->
453
+
<!--正解-->
454
454
<trv-is="'blog-post-row'"></tr>
455
455
```
456
456
457
457
:::
458
458
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 テンプレートを使用している場合、キャメルケースのプロパティ名やイベントハンドラのパラメータはそれと同等のケバブケース(ハイフンで区切られた記法)を使用する必要があります:
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 で遊んで楽しいものを作ってみることをお勧めします。
485
485
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.
0 commit comments