Skip to content
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

Nested page render the default layout even set to another layout #134

Closed
Discreater opened this issue Dec 17, 2023 · 2 comments · Fixed by #137
Closed

Nested page render the default layout even set to another layout #134

Discreater opened this issue Dec 17, 2023 · 2 comments · Fixed by #137

Comments

@Discreater
Copy link

I'm using unplugin-vue-router.
图片
图片

pages and layout structure:

src/pages
├── about.vue
├── index.vue
└── nested
    └── index.vue

src/layouts
├── alpha.vue
└── default.vue

about.vue and nested/index.vue are set to alpha layout. But they have different behavior.

reproduce repo: https://github.com/Discreater/double-layout

@JohnCampionJr
Copy link
Owner

This is a side effect of unplug-vue-router.

You'll need to create a src/pages/nested.vue with its layout set to false to disable the top level layout.

See the unplugin-vue-router example.

I'm going to leave this issue open in the hopes that we can find a solution but so far I've had no luck.

@AdamMerrifield
Copy link

Another temporary solution without creating a new file is modifying routes before passing them to setupLayouts. Effectively doing the same thing.

const nestedRoute = routes.find((route) => route.path === '/nested')

if (nestedRoute) {
  nestedRoute.meta = nestedRoute.meta ?? {}
  nestedRoute.meta.layout = false
}

const routesWithLayouts = setupLayouts(routes)

markthree added a commit to markthree/vite-plugin-vue-layouts that referenced this issue Dec 26, 2023
JohnCampionJr pushed a commit that referenced this issue Dec 27, 2023
…e children (#137)

* fix(unplugin-vue-router): skip top-level route layout for routing group, close #134

* fix: avoiding misses #97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants