File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,6 @@ Vue には [Web Components spec draft](https://github.com/w3c/webcomponents/blob
100
100
101
101
> 親のテンプレート内の全てのものは親のスコープでコンパイルされ、子のテンプレート内の全てのものは子のスコープでコンパイルされる。
102
102
103
-
104
103
## フォールバックコンテンツ
105
104
106
105
スロットに対して、コンテンツがない場合にだけ描画されるフォールバック (つまり、デフォルトの) コンテンツを指定すると便利な場合があります。例えば、` <submit-button> ` コンポーネントにおいて:
@@ -222,6 +221,7 @@ Vue には [Web Components spec draft](https://github.com/w3c/webcomponents/blob
222
221
</footer >
223
222
</div >
224
223
```
224
+
225
225
** ` v-slot ` は([ 一つの例外] ( #デフォルトスロットしかない場合の省略記法 ) を除き) ` <template> ` にしか指定できないことに注意してください。
226
226
227
227
## スコープ付きスロット
@@ -249,7 +249,6 @@ app.component('todo-list', {
249
249
250
250
親コンポーネントでこれをカスタマイズするために、` {{ item }} ` を ` <slot> ` に置き換えたい場合があります:
251
251
252
-
253
252
``` html
254
253
<todo-list >
255
254
<i class =" fas fa-check" ></i >
@@ -269,6 +268,16 @@ app.component('todo-list', {
269
268
</ul >
270
269
```
271
270
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
+
272
281
` <slot> ` 要素にバインドされた属性は、 ** スロットプロパティ** と呼ばれます。これで、親スコープ内で ` v-slot ` に値を指定して、渡されたスロットプロパティの名前を定義できます:
273
282
274
283
``` html
@@ -386,7 +395,6 @@ function (slotProps) {
386
395
387
396
` v-on ` や ` v-bind ` と同様に ` v-slot ` にも省略記法があり、引数の前のすべての部分 (` v-slot: ` ) を特別な記号 ` # ` で置き換えます。例えば、` v-slot:header ` は ` #header ` に書き換えることができます:
388
397
389
-
390
398
``` html
391
399
<base-layout >
392
400
<template #header >
You can’t perform that action at this time.
0 commit comments