Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

906
Visualizações
Nuxt 3 custom layout shows Invalid layout selected

I am trying to add a custom layout in a Nuxt 3 project, but that layout doesn't work, and the console shows this message:

Invalid layout test_layout selected

There is no other error.

This the code I have tried:

-| layouts/
 ---| test_layout.vue
-| pages/
 ---| blog/index.vue
<template>
  <div>
    My Test Layout Header
    <slot />
  </div>
</template>
<script>
export default {
  name: "test_layout"
}
</script>
<template>
  <div>
    <p>My Blog Title</p>
  </div>
</template>

<script>
export default {
  layout:"test_layout",
  name: "blog",
}
</script>

I have tried <Nuxt/> instead of <slot />, but it's not working.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Nuxt 3 seems to replace the filename's underscore with hyphens, so the layout should be specified as test-layout:

// blog/index.vue
export default {
  // layout: 'test_layout', // ❌ replace underscore with hyphen

  layout: 'test-layout', // ✅
}

demo

This wasn't an issue in Nuxt 2, which uses the exact filename as the layout name (including underscores). I also don't see any documentation about this. I've reported the issue to get some clarification.

over 4 years ago · Santiago Trujillo Relatório

0

Remove below code from your layout file. This may work.

<script>
    export default {
      name: "test_layout"
    }
</script>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda