I've created a CustomDataTable component based on <v-data-table>
:
CustomDataTable.vue
<template>
<div>
<v-container fluid>
<v-data-table
...
>
<!-- custom implementations -->
<v-data-table>
<v-container>
<!-- custom implementations -->
<div>
</template>
I had to add followings lines of code in order to use scoped item slots from child component (
CodePudding user response:
Default slot content is used only if parent component does not provide the content for that slot. But since your slot is defined for each slot content provided by the parent the content always exists and default is never used
Edit (after question edit): On the other side, if you do not pass any slot content into your CustomDataTable
(last code example), $scopedSlots
is empty, v-for
is not executed, no slot content is passed into v-data-table
and it uses default rendering...
CodePudding user response:
you have to remove slot
from this code. Becuase when you define the slot, you're ignoring The content inside it.
<template
v-for="(_, name) in $scopedSlots"
#[name]="slotData"
>
<slot
:name="name"
v-bind="slotData"
>
DEFAULT RENDER
</slot>
</template>
Also, there is another slot you have to define. Let me introduce the final code inside your CDatatable
Component:
<template
v-for="slot in Object.keys($scopedSlots)"
:slot="slot"
>
DEFAULT RENDER
</template>
<template v-for="(_, name) in $slots" #[name]>
DEFAULT RENDER
</template>