Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!