0👍
Waiting for some async request at page render is fine, just set empty initial values in the data
section of component like:
data() {
someStr: '',
someList: []
}
and make sure you handle the empty values well without undefined
errors trying to read things like someList[0].foo
.
Then when the request comes back, set the initially empty values to those real data you get from the request.
Giving the user some visual indicate that you’re fetching the data would be a good practice. I’ve found v-loading in element-ui useful for that.
- [Vuejs]-Toggle components based on prop value in main Vue instance
- [Vuejs]-Semantic UI sidebar in Vuejs webpack environment
Source:stackexchange.com