E
E
Eugene2021-08-05 12:03:12
Vue.js
Eugene, 2021-08-05 12:03:12

Why doesn't router handle nested route component?

If I specify routes in such a structure (everything in the root), then everything works.

[
    {
        path: '/hello',
        name: 'hello',
        component: Hello,
    }, {
        path: '/hello/test1',
        name: 'hello-test1',
        component: HelloTest1
    }, {
        path: '/hello/test2',
        name: 'hello-test2',
        component: HelloTest2   
    }
]


As soon as I wrap them in a nested route, then all nested routes are processed only by the parent component Hello
[
    {
        path: '/hello',
        name: 'hello',
        component: Hello,
        children: [
            {
                path: 'test1',
                name: 'hello-test1',
                component: HelloTest1
            }, {
                path: 'test2',
                name: 'hello-test2',
                component: HelloTest2
            }
        ]
    }
]


https://codesandbox.io/s/m6y4n
Understood my mistake, with a folded route, rendering is done by the parent component.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2021-08-05
@atachrus

Does the Hello component have a ? <router-view></router-view>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question