This commit is contained in:
Julien Huang 2024-11-20 06:35:52 -05:00 committed by GitHub
commit 57704665e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
import { isReadonly, reactive, shallowReactive, shallowRef } from 'vue'
import { isReadonly, reactive, shallowReactive, shallowRef, toValue } from 'vue'
import type { Ref } from 'vue'
import type { RouteLocation, RouteLocationNormalizedLoaded, Router, RouterScrollBehavior } from 'vue-router'
import { START_LOCATION, createMemoryHistory, createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
@ -114,6 +114,9 @@ const plugin: Plugin<{ router: Router }> = defineNuxtPlugin({
// so we need to update the route manually
if (to.matched[0]?.components?.default === from.matched[0]?.components?.default) {
syncCurrentRoute()
} else {
// assign toValue to avoid reactivity
Object.assign(toValue(_route), router.currentRoute.value)
}
})