-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Dynamically add child routes to an existing route #1156 #2064
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
Conversation
I do not know, but I think it may also be possible to integrate the parent route according to the name of the parent route. Thanks |
Hey, thanks for the PR. I'll need to take a deeper look, I'm not quite convinced by the API yet and would also like to make sure it works with 2-level nested children |
You're right, I apologize for that ... we need to check if it can be loaded at a second level of nesting, this should be similar to how the asynchronous loading of components in a route behaves. |
sorry for the delay, I have been very busy in my work @posva I'm not sure 100% of what I should try, I've done the following tests ... ` let components
components return....
this returns the three levels of routes, the main conditional is that the route to which you associate the daughter route must be created. Could you give me a guide of what is looked for in its entirety when adding a route to a parent route, thanks in advance. |
No worries, I'll come back at you. |
great, When does this feature released |
hey @posva, I see this issue is still awaiting triage in the project, any idea when it will make it into the flow and into a version of the router? If the API is still an open question, as I do see inconsistency myself, I would suggest it would follow the more standard
If it is agreed to change this, I have no problem doing it myself, but @Dri4n has done the work so far, so he certainly has first call. |
I think it's reasonable to force the usage of a name in a route for this router.addRoutes('name', [...])
router.addRoutes([...]) |
@posva |
Unfortunately, I don't have any estimate for this FR |
This comment has been minimized.
This comment has been minimized.
Are the any recommended workarounds or third-party libraries to utilize while this PR is up for review? |
@jake-harris before we get this released if you need simple work around you can store the entire route with the childrens in a varible and when you need to push new child update the varible childrens array and pass the entire route tree to the router.addRoutes() and this will overide any existing route configuration. Have a look at this example : https://yovchev.github.io/vue-dynamic-routes/ // src/views/NotFound.vue
import { DynamicRoutes } from '@/routes'
export default {
methods: {
loadMissingRoutes() {
// Load missing route
DynamicRoutes.children.push({
name: 'about',
path: 'about',
component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue')
})
// Update the routes
this.$router.addRoutes([DynamicRoutes])
}
}
} |
@yovchev - That's clever, I think that should get me where I need to be. Thanks! |
@Dri4n Sorry for the delay! Could you make the changes so adding routes to a parent requires a name: router.addRoutes('name', [...])
router.addRoutes([...]) |
Thanks, at the end this was added at ca80c44 |
Reason:
we need to add dynamic routes that are associated with a parent.
Unit Test:
router.addRoutes - from line "nested routes existing children relation".
Excuse me if this PR does not meet the guidelines, is my first PR in OpenSource.
Thanks!