-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Comments
That is normal, options is the object passed to the vuerouter constructor. It's not modified afterwards. |
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? |
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? |
how can you close this issue without solving the practical problem?@posva @yyx990803 |
@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! |
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 |
@posva Thank you for the reply, sure, please take your time. |
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? |
@posva any updates on requests in this thread asked by the community? |
See vuejs/rfcs#122 |
Version
3.0.1
when l add routes by addRoutes ,but $router.options.routes is not update
The text was updated successfully, but these errors were encountered: