Skip to content

dynamically change query and use router.push() but url don't update #6285

Discussion options

You must be logged in to vote

Underhood, router get currentRoute and to

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 isSameRouteLocation check queries

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]) &&
    isSameRouteLocat…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ylw5
Comment options

Answer selected by ylw5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants