I know this question may sound repetitive, but I've been searching for a solution for a long time, and couldn't find any.
I have a method that resolves a promise after the window is loaded. Later, I am waiting for that method in my mounted hook. When routing to that page, neither the promise itself, nor anything after it is executed. However, if I refresh the page, everything runs smoothly.
As an example, this is my method:
getPosition() {
return new Promise((resolve, reject) => {
window.addEventListener("load", () => {
console.log("window is loaded");
resolve();
});
});
},
This is my mounted hook:
async mounted() {
console.log("before promise"); // this logs
await this.getPosition(); // this does not log
console.log("after promise"); // this does not log
},