question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layout slots not working in default layout

See original GitHub issue

Environment

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:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Oct 15, 2022

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.)

0reactions
TJacoobcommented, Nov 5, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found