Answer the question
In order to leave comments, you need to log in
What does $emit do in Vue.js?
I read the doc, read other articles, watched vidos, but I can’t understand exactly what $emit does and when should it be used?
Answer the question
In order to leave comments, you need to log in
It simply fires an event that its parent component can subscribe to.
Note that these events do not "bubble" like js events, they are only for communication between two components. Which in practice will mean that if you need to transfer somewhere further, you need to issue it again, which is not very convenient.
But this is not much needed, because. all the same, everyone stores data in vuex, and does not drive data back and forth
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question