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

254
Visualizações
Vue children route

I was looking a way to make my static blog development more faster using vue-router, but I found a problem linking the children pages with the parent route.


    const routes = [
      {
        path: '/',
        name: 'Home',
        component: Home
      },
      {
        path: '/about', name: 'About', component: About,
        children: [
          { 
            path: '/test', name: 'How test children link', component: prova }
        ]
    
      }
    ]

If I try to go on localhost/about/test address Vue can't find the page, but I can reach it if I go directly to localhost/test.

If I change the children path to

    path: '/about/test', name: 'How test children link', component: prova }

It works, but, I don't understand the utility of the child route.

What I don't understand about children route?

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

0

You are on the right track. But you have to keep in mind that / means, and does, something.

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about', name: 'About', component: About,
    children: [
      { 
        path: 'test', name: 'AboutChild', component: TestComponent 
      }
    ]
  }
]

So basically do NOT include a / when adding a path for children. And if you do, add the whole path so in this case: path: '/about/test'

And equally as important, you won't see the contents of AboutChild until you had a html tag called <router-view /> in the About component.

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