[Vuejs]-Access and declare vueJs component inside other component slot

0👍

You can try like this:

<modal-component :ref="'deleteItemModal' + slotProps.item.id">
</modal-component>

Static value should be covered with quotation mark and can use + to concat any dynamic value with the string like in javascript.

To call openModal method of that ref component, create method in modal-component component

deleteItem(itemId) { this.$refs['deleteItemModal' + itemId].openModal() }

and then change for button click event

<button @click="deleteItem(slotProps.item.id)">

Leave a comment