Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  25] [ 4]  / answers: 1 / hits: 21831  / 6 Years ago, tue, september 18, 2018, 12:00:00

I am not able to $emit an event from a child component to it's parent.
I can successfully send the event, but not receive it in the parent.



Results.vue (Child):



<a href=# v-on:click=sendResultValues></a>

//

methods: {
sendResultValues: function () {
this.$emit('send-result-values', 'carrier');
}
},


When I click on the <a>, I can see with Vue DevTools that an $emit event is fired:



enter
However, nothing is received in the console.log as my code below (parent):



Input.vue (Parent):



<search-results></search-results> //Results.vue component
<search-popover v-on:send-result-values=showResultData></search-popover>
//
methods: {
showResultData: function () {
console.log(Data received from child: )
}
},

More From » vue.js

 Answers
2

You need to listen to the event on the search-results component, not on the search-popover.



Input.vue (Parent):



<search-results v-on:send-result-values=showResultData></search-results>
<search-popover></search-popover>

methods: {
showResultData: function () {
console.log(Data received from child: )
}
},

[#53471] Thursday, September 13, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
diamondlauryna

Total Points: 386
Total Questions: 93
Total Answers: 103

Location: South Korea
Member since Fri, Sep 11, 2020
4 Years ago
;