动态路由到嵌套路由不起作用Vue路由器

时间:2020-03-26 14:33:55

标签: vue.js vue-router router

因此从标题本身开始。关于动态路由,我有点问题。我有一个以myblog为根的URL

因此,当我进入myblog/blog时,它将列出所有博客文章,并且如果用户单击类别为myblog/category/some-category的链接,该链接将为用户提供链接。

但是,当我进入myblog/category/some-category并单击列表中的另一个类别时,我得到了这个奇怪的链接,即myblog/category/category/another-category

routes.vue
    const routes = [
        { path: '*', component: Home },
        {
            path: '/',
            component: Home,
            children: [
                {
                    name: 'blog',
                    path: '/blog',
                    component: BlogList,
                },
                {
                    name: 'post',
                    path: 'blog/:slug',
                    component: BlogPost,
                },
                {
                    name: 'category',
                    path: 'category/:slug',
                    component: CategoryList,
                },
                {
                    name: 'contact',
                    path: '/contact',
                    component: Contact,
                },
            ],
        },
    ];

如何链接它指向category/another-category,而不必再次创建category

0 个答案:

没有答案