@@ -41,16 +41,7 @@ import {
4141 stringifyQuery as originalStringifyQuery ,
4242 LocationQuery ,
4343} from './query'
44- import {
45- shallowRef ,
46- Ref ,
47- nextTick ,
48- App ,
49- ComputedRef ,
50- reactive ,
51- unref ,
52- computed ,
53- } from 'vue'
44+ import { shallowRef , Ref , nextTick , App , unref , shallowReactive } from 'vue'
5445import { RouteRecord , RouteRecordNormalized } from './matcher/types'
5546import {
5647 parseURL ,
@@ -1235,18 +1226,16 @@ export function createRouter(options: RouterOptions): Router {
12351226 } )
12361227 }
12371228
1238- const reactiveRoute = { } as {
1239- [ k in keyof RouteLocationNormalizedLoaded ] : ComputedRef <
1240- RouteLocationNormalizedLoaded [ k ]
1241- >
1242- }
1229+ const reactiveRoute = { } as RouteLocationNormalizedLoaded
12431230 for ( const key in START_LOCATION_NORMALIZED ) {
1244- // @ts -expect-error: the key matches
1245- reactiveRoute [ key ] = computed ( ( ) => currentRoute . value [ key ] )
1231+ Object . defineProperty ( reactiveRoute , key , {
1232+ get : ( ) => currentRoute . value [ key as keyof RouteLocationNormalized ] ,
1233+ enumerable : true ,
1234+ } )
12461235 }
12471236
12481237 app . provide ( routerKey , router )
1249- app . provide ( routeLocationKey , reactive ( reactiveRoute ) )
1238+ app . provide ( routeLocationKey , shallowReactive ( reactiveRoute ) )
12501239 app . provide ( routerViewLocationKey , currentRoute )
12511240
12521241 const unmountApp = app . unmount
0 commit comments