[Vuejs]-Passing Multiple Arguments to a Custom Event in Vue

3👍

I just recently did this in my project.
In your example of a ChildComponent and ParentComponent you can have

<ChildComponent @click="$emit('myEvent', 1)" />

<ParentComponent @myEvent="eventHandler(2, ...arguments)" />

Then your eventHandler would look like this

function eventHandler(parentArgument, childArgument) { ... }

You can probably change the ordering as you wish but this worked for me. Also just a side note I believe it’s recommended to use kebab-case for the html elements.

Leave a comment