-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed as not planned
Closed as not planned
Copy link
Description
Reproduction
https://codesandbox.io/p/sandbox/wonderful-violet-55q85o
Steps to reproduce the bug
- click the links on browser (no problem)
- type '/NoDynamic' at the end of URL in address bar and go to 'NoDynamic' page (no problem)
- type '/NestedA' or '/NestedB' at the end of URL on address bar then expected pages do not appear.(problem)
Expected behavior
I can move to the the dynamically added nested routes by typing the URL in the address bar.
Actual behavior
does not work.
Additional information
When I add nested routes dynamically and then try to access them by typing the URL in the address bar, it does not work. However, the routes work fine when accessed through RouterLink in the code. This issue only occurs with dynamically added nested routes, and there are no problems with static routes.
If there are no problems with my code, then it is probably a library issue. Adding nested routes works fine with Vue2 + Vue Router 3, but there seems to be an issue with Vue3 + Vue Router 4.
static router
const routes = [
{ path: "/", name: "home", component: HomeView },
{ path: "/NoDynamic", name: "NoDynamic", component: NoDynamic },
];
const router = createRouter({
history: createWebHistory(),
routes,
});dynamic rurter
const newRoutes = [
{
path: "/NestedA",
name: "NestedA",
component: () => import("@/views/NestedA.vue"),
},
{
path: "/NestedB",
name: "NestedB",
component: () => import("@/views/NestedB.vue"),
},
];
const layout = {
path: "/Nesting",
name: "Nesting",
children: newRoutes,
component: () => import("@/views/Nesting.vue"),
};
router.addRoute(layout);Thanks.
stefgodin
Metadata
Metadata
Assignees
Labels
No labels