Vue.js 3: Calling a parent method from a child component

'EventTester.vue' child component:

The child component publishes an event handler with the defineEmits macro. The defineEmits argument is an array of handler to publish.The defineEmits() macro cannot be used inside a function, it must be placed directly within <script setup>, as show here.

Read more about Vue.js 3 component events here.

To call the onTesting method passed in from the parent:

'App.vue' parent component:

The parent component passing a method with the @onTesting handler. The method passed will be called from the child with the emit call.

Leave a Comment

Your email address will not be published. Required fields are marked *