Answer the question
In order to leave comments, you need to log in
How to solve ctrl + f5 issue in vue.js?
This error occurs if you refresh the page with ctrl + f5:
Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'style' of null"
set_favourites_movies(state, data) {
state.favouritesMovies = data;
let arr = [];
for (let key in data) {
arr.push(data[key]);
}
for (let key of arr) {
document.querySelector(key).style.color= "red";
}
},
Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'style' of null"
Answer the question
In order to leave comments, you need to log in
Apparently, selectors get into localstorage later than document.querySelector(key) reads them. With a simple F5, storage still has these values, so it reads normally. With ctrl+F5 storage is cleared and the first time there is nothing there, until something fills it up.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question