-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Provide method to get all routes #2940
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
Comments
Yes, this is somewhat important data to get.
but it doesn't work for children and same path routes. |
It will be good to have them all in one place, as for example here: |
I've tried a simple solution with returning the |
@iamnotblank thanks! This method is unlikely to be added to the current version of Vue Router to avoid adding more breaking changes 😅 |
Added at 6bc30aa with limited functionality compared to v4 |
What problem does this feature solve?
If an application is split into several Vue components/libraries, each component can add their specific routes using router.addRoutes(array).
In the main application we then want to dynamically create menu items from all available routes. Currently there seems to be no way to get all routes, including those added with addRoutes().
We've done a workaround by importing routes manually from all included components and appending them into one array. This array is then used when constructing the router instance. It's a lot of boilerplate and easy to miss an import. A Router.getRoutes() method would really help in this use-case.
What does the proposed API look like?
router.getRoutes()
orrouter.getAllRoutes()
that returns an array of route configurations.The text was updated successfully, but these errors were encountered: