[Vuejs]-Passing data from dynamic components as an object to parent component

0👍

Emit an event from the child.

In the parent subscribe to that event

<component v-for="itemRow in itemRows" :is="itemRow" @onChange="updateRow"></component>

You’ll also need to pass the index to the child so the parent knows from which element it’s receiving the event

<component v-for="(itemRow, index) in itemRows" :is="itemRow" :index="index" @onChange="updateRow"></component>

This means that you need to define a prop on the child component(s).

Remember to update the array using Vue.set/this.$set, otherwise you’re array won’t be reactive.

Leave a comment