Skip to content
Advertisement

Usage of asynchronous response data in asynchronous components

Below is the parent component and child component enter code here

JavaScript

I want to draw a new chart whenever the $store(vuex) data changes. However, since the response of this data is asynchronous, when the child component is loaded, it may or may not have received the data(in Parent component). I always want to draw a chart with the data I received when the child component was initially loaded. The components of vue are also asynchronously loaded, so in this case, how can I control it? As of now, if the child component is initially loaded, the chart may or may not be drawn. I look forward to answering from the vue expert. Thank you.

Advertisement

Answer

You can use mapState() and watch():

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