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

278
Visualizações
Nested directory nuxt 3 + Vite

I want to use nested directory in nuxt 3 beta with vite.

In Nuxt 2 i was using this config in (nuxt.config.js) and it work :

components: [
{
  path: '~/components', // will get any components nested in let's say /components/test too
  pathPrefix: false,
},],

I have this directory organisation:

| components
 - Header.vue
 - Footer.vue
 | sections
  - HeroSection.vue

but i got this error when i try to put <HeroSection/> in pages/index.vue.

[Vue warn]: Failed to resolve component: HeroSection
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
Invalid value used as weak map key

does it no longer work in nuxt 3 and there is another configuration to do? Because I find nothing about it on the doc

Thank <3

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Using nested directories requires prepending the name of the directory onto the component:

<template>
  <SectionsHeroSection />
</template>

With this behavior you can be less complex about naming your components:

- components
    Header.vue
    Footer.vue
  - Sections
      Hero.vue

So that we can use like so

<template>
  <SectionsHero />
</template>

Read more in the docs here: https://v3.nuxtjs.org/guide/directory-structure/components#component-names

about 4 years ago · Juan Pablo Isaza Relatório

0

I found this on the doc:

import { join } from 'pathe'
import { defineNuxtModule } from '@nuxt/kit'

export default defineNuxtModule({
  hooks: {
    'components:dirs'(dirs) {
      // Add ./components dir to the list
      dirs.push({
        path: join(__dirname, 'components'),
        prefix: 'awesome'
      })
    }
  }
})

https://v3.nuxtjs.org/docs/directory-structure/components/

But it desn't work with this config:

hooks: {
    'components:dirs'(dirs) {
      // Add ./components dir to the list
      dirs.push({
        path: join(__dirname, 'components/sections'),
        prefix: false
      })
    }
  }
about 4 years ago · Juan Pablo Isaza 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