Is it possible to nest routes like with Vue Router? #711
-
I tried to migrate from normal Vue Router to unplugin-vue-router but I am having a hard time with route nesting. I prepared this CodeSandbox to demonstrate what I want.
But I don't know how without heavily duplicating all my files time and time again. However It seems I have to duplicate my "Layout" or "Root" files for each nested folder I want to use. So I kinda end up with a structure like ![]() Within my current project I would have to create around 30 duplicate useless files as the structure would become
Because Item3, Item2 and Item1 should be a child of Home.vue and use the very same layout. Or in Other words: in case I have 1 "layout" component and 10 other components should extend this layout component. In Vue Router I can add this layout component and 10 Children to it. What is the correct way with this library without having to duplicate my single layout component 10 times - once for each child? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Are you using a |
Beta Was this translation helpful? Give feedback.
-
Thank you for coming along. |
Beta Was this translation helpful? Give feedback.
-
https://uvr.esm.is/guide/file-based-routing.html#nested-routes |
Beta Was this translation helpful? Give feedback.
-
@PindaPixel I know that and that's in my example. The link does not explain how to get rid of multiple duplicate files.
However when I have another folder that should be a child of
while another and users have equal content. When I have one layout component and 5 different paths in that layout component, I would need that layout component 5 times. |
Beta Was this translation helpful? Give feedback.
-
You want reusable layouts. Currently, the way to achieve this is creating a component with a slot and use it where needed. I opened #712 because I potentially want to add it but I'm a bit worried about how will this integrate with Nuxt |
Beta Was this translation helpful? Give feedback.
You want reusable layouts. Currently, the way to achieve this is creating a component with a slot and use it where needed. I opened #712 because I potentially want to add it but I'm a bit worried about how will this integrate with Nuxt