dynamically change query and use router.push() but url don't update #6285
-
deep clone route.query and then change the property of new query,it works (url changes)
but if I change property in route.query and then deep clone changed route.query,it cannot work (url not changes)
use
I know alter query directly is not correct. But It still confuses me, because I get two same object and pass to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Underhood, router get Code fragment(can't add snippet from another repo) const targetLocation: RouteLocation = (pendingLocation = resolve(to))
const from = currentRoute.value
...
if (!force && isSameRouteLocation(stringifyQuery, from, targetLocation)) { And in function isSameRouteLocation(
stringifyQuery: (query: LocationQueryRaw) => string,
a: RouteLocation,
b: RouteLocation
): boolean {
const aLastIndex = a.matched.length - 1
const bLastIndex = b.matched.length - 1
return (
aLastIndex > -1 &&
aLastIndex === bLastIndex &&
isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) &&
isSameRouteLocationParams(a.params, b.params) &&
stringifyQuery(a.query) === stringifyQuery(b.query) &&
a.hash === b.hash
)
} But you mutate |
Beta Was this translation helpful? Give feedback.
Underhood, router get
currentRoute
andto
Code fragment(can't add snippet from another repo)
And in
isSameRouteLocation
check queries