vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.75k stars 1.15k forks source link

Route Grouping #2204

Closed aryankarim closed 3 months ago

aryankarim commented 3 months ago

What problem is this solving

Having route grouping helps:

Proposed solution

This code below currently does not work. The 404 page is not being found be the router since it is a child.

Not having to put path and component the vue router should understand that this is just a group not a prefixed/nested child.

reateRouter({
  routes: [
    {
      name: "public",
      meta: { layout: "Public", public: true },
      children: [
        {
          path: "/home",
          name: "Home",
          component: () => import("../path/to/Home.vue"),
        },
        {
          path: "/login",
          name: "Login",
          component: () => import("../path/to/Login.vue"),
        },
        {
          path: "/:pathMatch(.*)*",
          component: () => import("../path/to/404.vue"),
        },
      ],
    },
  ],
});

Describe alternatives you've considered

No response

posva commented 3 months ago

You just need to add the path. In the root, it's /. The name can (and should) be removed as you don't want to visit a route group.