fix(nuxt3): initialize router with normalized url (#4427)

This commit is contained in:
Daniel Roe 2022-04-19 15:37:08 +01:00 committed by GitHub
parent 7a316c289a
commit 90da56a03b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,7 +82,7 @@ export default defineNuxtPlugin((nuxtApp) => {
} }
// Allows suspending the route object until page navigation completes // Allows suspending the route object until page navigation completes
const path = process.server ? nuxtApp.ssrContext.req.url : createCurrentLocation(baseURL, window.location) const path = process.server ? nuxtApp.ssrContext.url : createCurrentLocation(baseURL, window.location)
const _activeRoute = shallowRef(router.resolve(path) as RouteLocation) const _activeRoute = shallowRef(router.resolve(path) as RouteLocation)
const syncCurrentRoute = () => { _activeRoute.value = router.currentRoute.value } const syncCurrentRoute = () => { _activeRoute.value = router.currentRoute.value }
nuxtApp.hook('page:finish', syncCurrentRoute) nuxtApp.hook('page:finish', syncCurrentRoute)