Open evgenii-code opened 4 months ago
The following workarounds are available
router.push(path, onCompleted)
In your reproduction environment, you could write
const pushToTodosWithAwait = async () => {
showRouteName(1);
router.push(route, () => {
showRouteName(3);
});
};
router.push(path, onCompleted)
Yes, we are currently using this workaround in our app.
The downside is that the newer version of vue-router does not have an onComplete
callback, if I'm not mistaken. We need to keep this in mind after the migration is complete.
Environment
Reproduction
Nuxt Bridge reproduction https://stackblitz.com/edit/nuxt-bridge-starter-nbqmvf?file=pages%2Findex.vue
Nuxt 3 reproduction https://stackblitz.com/edit/nuxt-starter-me3k42?file=pages%2Findex.vue
Describe the bug
Utility helper
navigateTo
does not return a promise, thus cannot be awaited.The method
router.push
has the same behaviour. You may notice, that the app crashes onrouter.push('/').then(() => {})
, because there is no.then
inundefined
In this Nuxt Bridge reproduction I have tried to add
await
to thenavigateTo
, and second alert fires synchronously.But in Nuxt 3,
await
makes the difference and second alert fires after navigation complete.A little bit of code
pages/index.vue ```VueAdditional context
No response
Logs
No response