Skip to content
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

add routes by addRoutes will not show in $router.options.routes #1859

Closed
PanJiaChen opened this issue Nov 1, 2017 · 10 comments
Closed

add routes by addRoutes will not show in $router.options.routes #1859

PanJiaChen opened this issue Nov 1, 2017 · 10 comments

Comments

@PanJiaChen
Copy link

PanJiaChen commented Nov 1, 2017

Version

3.0.1

when l add routes by addRoutes ,but $router.options.routes is not update

@posva
Copy link
Member

posva commented Nov 1, 2017

That is normal, options is the object passed to the vuerouter constructor. It's not modified afterwards.

@posva posva closed this as completed Nov 1, 2017
@tadada
Copy link

tadada commented Mar 12, 2018

After ‘addRoutes’, the routers added can accessable, but can not be found in this.$router object. So how can I get added routers? Or save a copy instead?

@fayt81
Copy link

fayt81 commented Mar 22, 2018

It's ok that options.routes are those passed during initialization, but then we need a method to get also routes added with addRoutes. What about exposing an array with all routes such as this.$router.routes?

@shaqueoneal
Copy link

how can you close this issue without solving the practical problem?@posva @yyx990803

@jinweijie
Copy link

@posva it's reasonable that $router.options.routes not modified afterwards, but is there any method available to retrieve the current routes? for me, after addRoutes succeeded there should be a way to get the current routes which are available. Thanks!

@posva
Copy link
Member

posva commented Jul 16, 2018

right now you need to keep a copy of current routes as you add them. This is because vue-router is designed about static routes, so there are things not quite possible regarding full dynamic routing and we don't want to rush all features

@jinweijie
Copy link

@posva Thank you for the reply, sure, please take your time.

@fayt81
Copy link

fayt81 commented Jul 18, 2018

Hi @posva, as suggested, I am currently storing an array with the routes added dynamically, so that it can later be used by the rest of my code. However, since all the routes (including dynamically added ones) should be already stored somewhere to get the routing working, why not just exposing the variable where they are actually stored? Could you kindly explain what is critical in exposing it?

@milost1982
Copy link

@posva any updates on requests in this thread asked by the community?

@vuejs vuejs deleted a comment from erg Feb 22, 2020
@posva
Copy link
Member

posva commented Feb 22, 2020

See vuejs/rfcs#122 getRoutes

@vuejs vuejs locked as resolved and limited conversation to collaborators Feb 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants