Reputation: 14924
I have following scenario:
I have an dropdown component. Whenever you select some propertie it emits the selected value in my case the color with
this.$emit("setColor", "somecolor")
In my parent component i listen to this event with <mycomponent @setColor="setColor" />
and execute an method called setColor
This component is actually rendered in a v-for
and for this i want to pass my index of the current iteration to the setColor
, how do i do that?
i tried with @setColor="setColor(i)"
but then my color that i am passing from the child to the parent is undefined
Upvotes: 0
Views: 393
Reputation: 10790
You can use $event
keyword to pass the event payload. So you can call your method like below :
@setColor="setColor($event,i)"
Upvotes: 1