[Vuejs]-Emitting data from chiled to parent using vue.js and laravel

0👍

You are emiting here:

this.$emit('userData', index)

Which means the name of your event is 'userData'. That’s what you have to listen to in the parent. But if you check your parent, you are listening to the event like this:

v-on:showusersdata1="userData($event)"

This means you are trying to listen to the 'showusersdata1' event, which is not fired. You are confusing the method name in your child for your event name. Instead of what you did, you can listen to your event like this:

v-on:userData="userData"

It’s also kind of a convention to name event listeners by adding “on” in front of them, example:

  • event name is 'userDataReceived'
  • event listener would be onUserDataReceived

Leave a comment