2

My App works just fine, if I put routes without childrens (nesting) but I tried to nest it just now and converted my routes to this: in routes.js

import alphabetsPage from './components/views/pages/alphabets.vue'
import dictionaryPage from './components/views/pages/dictionary.vue'
import numbersPage from './components/views/pages/numbers.vue'

import LayoutView from './components/views/Layout.vue'

const routes = [{

  path: '/',
  name: 'Home',
  component: LayoutView,
    children: [{
        path: 'basic',
        name: 'Basic',
        component: alphabetsPage,
          children: [{
            path: 'alphabets',
            name: 'Aphabets',
            component: alphabetsPage           
          },
          {
            path: 'numbers',
            name: 'Numbers',
            component: numbersPage           
          }]
    }]
}]

export default routes

If I go to / or click on route <router-link to="/basic/alphabets" tag="li"><a>numbers</a></router-link> I can see the alphabetsPage component, however if I go click on <router-link to="/basic/numbers" tag="li"><a>numbers</a></router-link> the route doesn't work. I have a numbersPage componet working.

This must be from the routes, because, if I don't use children and just define the path in routes as /basic/numbers or /basic/alphabets it works.

1
  • What if you change the "numbers" path to " /basic/alphabets/numbers"? If I understand your setup, it appears numbers is a child of alphabets which is a child of basic? Maybe a plunkr setup would be helpful. Commented Sep 9, 2017 at 20:31

1 Answer 1

1

Children should be shown somewhere.

Your alphabetsPage do not have in template

const alphabetsPage = {
    template: '<div>/basic/alphabets <router-view></router-view></div>'
}

https://jsfiddle.net/6fvL1xwc/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.