Skip to content

Migrating vue-router from v3 to v4 results in unexpected changes to Router signature from createRouter #1975

Closed Answered by arggrande
arggrande asked this question in Help and Questions
Discussion options

You must be logged in to vote

I've figured out what was happening here.

Basically in the latest version of vue-router, the currentRoute object was changed to a reactive object, which meant that to access the underlying properties like query, params or fullPath in a normal javascript file (as opposed to a Vue template file), you needed to add a .value to the property chain.

Here's a diff of what I mean:

-const myQueryProperty = router.currentRoute.query.customProperty;
+const myQueryProperty = router.currentRoute.value.query.customProperty

I've raised a PR (see #1976) to update the migration docs, hopefully this is useful to someone else!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by arggrande
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #1974 on August 29, 2023 07:08.