When we need a custom component to emit an event in VueTable2, we must use:
this.$parent.$emit('myCustomEvent')
// instead of
this.$emit('myCustomEvent')
This thread tells us more about this aspect.
I used to run this.$emit()
when I had to trigger an event. I was wondering what are the main differences between the two of them?
Vue $emit is a function that lets us emit, or send, custom events from a child component to its parent. In a standard Vue flow, it is the best way to trigger certain events.
The correct way to use props and $emit Following is the flow what vue design. Parent has data to control, pass data to child component by props. If child component need to deal with props data, assign props data value to itself's data when component mounted. After handle method, parent open a interface to child.
this.$emit
dispatches an event to its parent component.
this.$parent
gives you a reference to the parent component.
As you might have guessed, this.$parent.$emit
will make the parent dispatch the event to its parent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With