Skip to content
Advertisement

VUE JS passing object to children after mounted

I have three vue components. One is the page listing, it includes a filter and a list. When the page listing component is rendering, it needs to parse some JSON and passing that object into the filter component. Where I see that there is a problem is that the mounted script is running after the filter component has been rendered, therefore, no object has been passed inside of the filter to render, how do i bypass that ? I have checked the vue cycle but I cannot for the life of me figure out what the problem is.

On the filter component, when I output {{test}} it shows the right text ‘yayaya’ because its a string, and it’s not passing an object that needs to be manipulated. Why is it that when I output {{dataTagGroups}} on the filter component it returns nothing, it’s empty.

LISTING PAGE COMPONENT

JavaScript

FILTER COMPONENT

JavaScript

Advertisement

Answer

You could initially set your dataTagGroups and dataSortOptions in the data as null and only display the filter if those aren’t null anymore.

JavaScript

in your template you can then use v-if to only render the filter if those conditions are met.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement