Reputation: 523
Inside vue component I have another child component datatabel
which has emitted method sort
<datatable @sort="sortBy"></datatable>
Currently the emitted sort
method calls another method sortBy
in parent component, which then updates a property in the parent.
Is it possible to update the parent property directly form emitted sort
method?
Something like this:
<datatable @sort="parentAttribute = 'value that was emitted'"></datatable>
The above example doesn't work, but I am not probably doing it right.
Can that be done, if so, what would be the right syntax?
Upvotes: 0
Views: 207
Reputation: 3820
Yes you can access the event payload with $event
<datatable @sort="parentAttribute = $event"/>
https://v2.vuejs.org/v2/guide/components-custom-events.html
Upvotes: 1