Answer the question
In order to leave comments, you need to log in
Why does $emit send 1 event and 2 arrive?
Hello.
I want to send an event to the bus on the esc button.
I do it like this
@keyup.esc="busSend"
busSend() {
bus.$emit('tableCell',{
nodeData:this.nodeData
})
}
bus.$on("tableCell", data => {
console.log(data)
});
Answer the question
In order to leave comments, you need to log in
It seems that there are only two options - busSend fires twice, or the subscription to this event occurs twice. Insert a console.log before bus.$on to check how many times the subscription occurs.
You need to unsubscribe in the destroyed hook or before subscribing:
bus.$off("tableCell")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question