New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current route's query unaccessible on the App's created hook when using lazy loaded routes #2495

ThomasFerro opened this Issue Nov 23, 2018 · 4 comments


None yet
2 participants

ThomasFerro commented Nov 23, 2018



Reproduction link

Steps to reproduce

  • Start a new vue-cli 3 project with vue-router
  • In the App.vue component, add this created hook :
created() {
  console.log('created', this.$route.query, this.$route.query && this.$route.query.test);
  • Run the application using the url http://localhost:8080/#/about?tiers=tezst

What is expected?

The query should be present in the this.$route object.

What is actually happening?

It is not.

Sorry but I cannot get vue-router working on the online IDEs.

I think this is due to the lazy loading because it does works however when calling the home page http://localhost:8080/#/?tiers=tezst.


This comment has been minimized.


posva commented Nov 23, 2018

Was this working in the previous version? I'm having a hard time reproducing with an older version with code sandbox and I cannot test very well


This comment has been minimized.

ThomasFerro commented Nov 25, 2018

Hi, I don't know if it worked before but I can send you a minimalist project where the issue is reproduced ?


This comment has been minimized.


posva commented Nov 25, 2018

no, don't worry. Now that I'm home I can check it on a computer 😄


This comment has been minimized.


posva commented Nov 25, 2018

What's happening is that because the route is lazy loaded, we need to wait for it and its navigation guards before actually triggering the navigation, so when we land on the /, we are still not in the actual / route during the created hook, so the $route property isn't up to date. If you change the path of the lazy loaded route to something like /no, you will see that the $route object still contains / (this should help visualise what is actually happening)

@posva posva closed this Nov 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment