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 PanJiaChen commented Nov 1, 2017

Version

3.0.1

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

@posva

This comment has been minimized.

Copy link
Member

@posva 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 Nov 1, 2017
@tadada

This comment has been minimized.

Copy link

@tadada 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

This comment has been minimized.

Copy link

@fayt81 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

This comment has been minimized.

Copy link

@shaqueoneal shaqueoneal commented May 15, 2018

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

@jinweijie

This comment has been minimized.

Copy link

@jinweijie jinweijie commented Jul 16, 2018

@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

This comment has been minimized.

Copy link
Member

@posva 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

This comment has been minimized.

Copy link

@jinweijie jinweijie commented Jul 18, 2018

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

@fayt81

This comment has been minimized.

Copy link

@fayt81 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

This comment has been minimized.

Copy link

@milost1982 milost1982 commented Dec 15, 2019

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

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

This comment has been minimized.

Copy link
Member

@posva 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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.