Skip to content
Advertisement

Access data property of child component from parent vue 3 typescript and composition api

I have setup two components parent and child:

App.vue //Parent

JavaScript

BookForm.vue //child

JavaScript

I’ve followed this thread from vue forum for the solution but I cannot retrieve data from child component into parent component.

When I console log console.log(bookRef.value) I get undefined. What is the correct way to get child component’s data with typescript and composition api setup tag ?

Advertisement

Answer

Try to use defineexpose to expose the child component properties to the parent one :

JavaScript
Advertisement