Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

My emit doesnt work, I cant send any data to parent

This is my code – child:

<a-camp :camp="camp.name" @click="$emit('camp-selected', camp)" />

export default {
    emits: ['camp-selected'],
...

parent:

<a-camp-select @camp-selected="campSelected(camp)"></a-camp-select>

When I try emit without -camp- parameter it works, I can console log test, but when I add -camp-, I cant get it to parent, I also try console log camp in child component and it works. So there is problem somewhere in the middle. Any hints?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should not mention the parameter when you set the handler for the emitted event @camp-selected="campSelected(camp)":

<a-camp-select @camp-selected="campSelected">

you’ve to mention it inside the method definition:

methods:{
  campSelected(camp){
    //use camp here 
  }
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading