Skip to content

Commit cde593c

Browse files
committed
1 parent 3918ee2 commit cde593c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/guide/component-slots.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ Vue には [Web Components spec draft](https://github.com/w3c/webcomponents/blob
100100

101101
> 親のテンプレート内の全てのものは親のスコープでコンパイルされ、子のテンプレート内の全てのものは子のスコープでコンパイルされる。
102102
103-
104103
## フォールバックコンテンツ
105104

106105
スロットに対して、コンテンツがない場合にだけ描画されるフォールバック (つまり、デフォルトの) コンテンツを指定すると便利な場合があります。例えば、`<submit-button>` コンポーネントにおいて:
@@ -222,6 +221,7 @@ Vue には [Web Components spec draft](https://github.com/w3c/webcomponents/blob
222221
</footer>
223222
</div>
224223
```
224+
225225
**`v-slot` は([一つの例外](#デフォルトスロットしかない場合の省略記法) を除き) `<template>` にしか指定できないことに注意してください。
226226

227227
## スコープ付きスロット
@@ -249,7 +249,6 @@ app.component('todo-list', {
249249

250250
親コンポーネントでこれをカスタマイズするために、`{{ item }}``<slot>` に置き換えたい場合があります:
251251

252-
253252
```html
254253
<todo-list>
255254
<i class="fas fa-check"></i>
@@ -269,6 +268,16 @@ app.component('todo-list', {
269268
</ul>
270269
```
271270

271+
You can bind as many attributes to the `slot` as you need:
272+
273+
```html
274+
<ul>
275+
<li v-for="( item, index ) in items">
276+
<slot :item="item" :index="index" :another-attribute="anotherAttribute"></slot>
277+
</li>
278+
</ul>
279+
```
280+
272281
`<slot>` 要素にバインドされた属性は、 **スロットプロパティ** と呼ばれます。これで、親スコープ内で `v-slot` に値を指定して、渡されたスロットプロパティの名前を定義できます:
273282

274283
```html
@@ -386,7 +395,6 @@ function (slotProps) {
386395

387396
`v-on``v-bind` と同様に `v-slot` にも省略記法があり、引数の前のすべての部分 (`v-slot:`) を特別な記号 `#` で置き換えます。例えば、`v-slot:header``#header` に書き換えることができます:
388397

389-
390398
```html
391399
<base-layout>
392400
<template #header>

0 commit comments

Comments
 (0)