Layout slots not working in default layout
See original GitHub issueEnvironment
Nuxt 3.0.0-rc.11
Reproduction
StackBlitz: https://stackblitz.com/edit/nuxt3-layout-slot-bug
Describe the bug
Layout slots not working with default layout, generate error (see reproduction):
Error: Codegen node is missing for element/if/for node. Apply appropriate transforms first.
Note the use of app.vue
.
Explicitly using <NuxtLayout>
with layout: false
in page meta works but leads to full re-render of the layout and kinda defies the purpose of a default layout.
Not sure if I’m doing something wrong with the setup, but following the docs, the code in the repro should work. Also, best in terms of DX IMO.
Additional context
This is a typical use case where you for instance have a nav and want to add additional items via a slot on specific pages.
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
support the use of slot in layout files · Issue #190 · nuxt/nuxt.js
Hi @dohomi. It's not possible with layouts logic of nuxt.js since it's based on vue-router . But nothing is impossible with vue.js.
Read more >My dynamic component (layout) doesn't work with named slots ...
I have problems to combine dynamic generated layouts with named slots. 'v-slot' directive must be owned by a custom element, but 'div' is...
Read more >Vue 3 named not working with default Inertia layout - Laracasts
Hi, I have a simple layout with two slots, one for a header and one for the main content but for some reason...
Read more >layouts/ · Nuxt Directory Structure
Enabling the Default Layout In a layout file, the content of the layout will be loaded in the <slot /> , rather than...
Read more >Nested layouts in Nuxt/Vue.js - Constant Solutions
This is luckily a fairly easy thing to do, expect you need to do a bit of tweaking. Assuming you haven't modified your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That is absolutely something on my list, and currently pending https://github.com/vuejs/core/pull/6736.
(It’s not currently possible due to vue behaviour, but should be once that PR merges.)
Just to add to this, I think it makes some sense as an enhancement. A simple use case would be to have a layout where the screen is split in half, with a slot for each side, and in each page would pass different data to each slot.
For example, login / signup pages often follow the same layout but might have different forms on the screen, along with different texts and information.