P
P
phpForeve2017-05-13 13:17:20
JavaScript
phpForeve, 2017-05-13 13:17:20

How do children work in the Vue router?

All routes work except the last one (example.com/news/create) - How to write a route correctly to make it work.

{
        path: '',
        component: Main,
        children: [
            {
                path: '',
                name: 'index-page',
                component: Index
            },
            {
                path: 'homes',
                name: 'homes-list',
                component: Homes
            },
            {
                path: 'news',
                name: 'news-index',
                component: News,
                children: [
                    {
                        path: 'news/create',
                        name: 'news-create',
                        component: NewsCreate,
                    }
                ]
            },
        ]
    },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-05-13
@phpForeve

Replace:

children: [
                    {
                        path: 'news/create',
                        name: 'news-create',
                        component: NewsCreate,
                    }
                ]

on the :
children: [
                    {
                        path: 'create',
                        name: 'news-create',
                        component: NewsCreate,
                    }
                ]

?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question