The problem of VUEX asynchronously refreshing the bound value of the interface

when working on a MPVUE project, when the project is running and starting, there is an asynchronous method in app.vue (think of it as an entry program) that calls API. After the method is executed, the obtained parameters are assigned to the variables in $state. At this time, the client has already entered the main page, and the content displayed in the binding on the main page is the value in $state. Because it is slow to get the API return value at first, the corresponding content is not displayed on the main page.

there are two problems. How to solve the above situation? For example, let the API Synchronize request in app.vue display for a while the loading, request and then go to the main page?

When the value in the $state of

vuex changes, how to update the place where it is bound at the same time? Using the watch method?

Jul.09,2021
I have encountered the problem of

before. The first method I use is to get the data after return , and then modify the assignment. The second way is to use the calculation attribute computed and then return this.$store.state.xxx

Menu