0👍
There are subtle differences between mounted
and created
in your case since you want to manipulate the DOM, you should use mounted
lifecycle hook.
This answer would expound on the differences between the two lifecycle methods.
0👍
This is a working example of what you’re trying to do: https://codesandbox.io/s/blissful-field-kjufc?file=/src/App.vue
The interesting part of the code is here:
async created() {
const response = await fetch("https://jsonplaceholder.typicode.com/photos");
const json = await response.json();
console.log("done loading the data");
if (json) this.isLoading = false;
},
You can go to your network tab and select "slow 3G" to have an emulated slow connection. That way, you will see that the VueJS logo is not displayed until we have fetched all the 5000 photos.
If it’s not helping, we definitely need more details, like vue devtools debugging or a reproduction.
- [Vuejs]-Not sure why I am getting "error 'Navbar' is defined but never used" when using Vue
- [Vuejs]-NuxtJS: How to access Vuex state on Server side
Source:stackexchange.com