Skip to content
Discussion options

You must be logged in to vote

This is because all navigations are async, you need to wait for the router to be ready: https://router.vuejs.org/guide/migration/#All-navigations-are-now-always-asynchronous

async mounted() {
  await this.$router.isReady()
  this.$route.query.length
}

In your case you should just use a computed instead of setting it in data:

computed: {
  length() {
    return this.$route.query.length
  }
}

That way, the variable will update whenever it's ready

Replies: 1 comment

Comment options

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

This discussion was converted from issue #2001 on September 27, 2023 19:05.