Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vuetify/Vue3 slots shadowing between templates

I am looking for the correct way to display an object from a parent template in a child template. However, in the following case the objects both have the same name and the object in the parent template is being shadowed. Is there an easy way to rename one or do I have to do something more complex to be able to show both values in the child template?

<v-data-table :items="someParentItems" ...>
 <template v-slot:expanded-row="{ columns, item }">
   PARENT {{ item }}
   <v-data-table :items="someChildItems" ...>
     <template #item.someField="{ item }">
       CHILD {{ item }} <!-- Would really like CHILD {{ parentItem }} {{ childItem }} -->
     </template>
   </v-data-table>
 </template>
</v-data-table>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It’s just simple object destructuring, you can set new names after a colon:

<v-data-table :items="someParentItems" ...>
 <template v-slot:expanded-row="{ columns, item: parentItem }">
   PARENT {{ parentItem }}
   <v-data-table :items="someChildItems" ...>
     <template #item.someField="{ item: childItem }">
        CHILD {{ parentItem }} {{ childItem }}
     </template>
   </v-data-table>
 </template>
</v-data-table>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading