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
Copy file name to clipboardExpand all lines: src/guide/components/slots.md
+24-20Lines changed: 24 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -443,34 +443,38 @@ Note the `name` of a slot won't be included in the props because it is reserved
443
443
444
444
If you are mixing named slots with the default scoped slot, you need to use an explicit `<template>` tag for the default slot. Attempting to place the `v-slot` directive directly on the component will result in a compilation error. This is to avoid any ambiguity about the scope of the props of the default slot. For example:
445
445
446
+
```vue-html
447
+
<!-- <MyComponent> template -->
448
+
<div>
449
+
<slot :message="hello"></slot>
450
+
<slot name="footer" />
451
+
</div>
452
+
```
453
+
446
454
```vue-html
447
455
<!-- This template won't compile -->
448
-
<template>
449
-
<MyComponent v-slot="{ message }">
456
+
<MyComponent v-slot="{ message }">
457
+
<p>{{ message }}</p>
458
+
<template #footer>
459
+
<!-- message belongs to the default slot, and is not available here -->
450
460
<p>{{ message }}</p>
451
-
<template #footer>
452
-
<!-- message belongs to the default slot, and is not available here -->
453
-
<p>{{ message }}</p>
454
-
</template>
455
-
</MyComponent>
456
-
</template>
461
+
</template>
462
+
</MyComponent>
457
463
```
458
464
459
465
Using an explicit `<template>` tag for the default slot helps to make it clear that the `message` prop is not available inside the other slot:
0 commit comments