I'm using Vuetify and made a component including a v-data-table
. How could I change the table column templates in the parent component?
Child component example:
<template>
<v-card>
<v-data-table :items="items" :headers="headers">
<!-- ???????? -->
</v-data-table>
</v-card>
</template>
<script>
export default {
name: "ChildComponent",
props: {
items: Array,
headers: Array,
},
};
</script>
Parent component:
The item.id
is just an example, I need a common solution for any kind of object field.
<template>
<ChildComponent :items="items" :headers="headers">
<template v-slot:item.id="{ item }">
<v-chip> {{ item.id }} </v-chip>
</template>
</ChildComponent>
</template>
<script>
import ChildComponent from "./ChildComponent";
export default {
components: {
ChildComponent,
},
data: () => ({
items: [/* ... */],
headers: [/* ... */],
}),
};
</script>
I guess I need dynamic slots but not really know how to use them in this case.