vue嵌套路由子路由 path 注意

子路由的地址如果是希望拼接父路由地址,子路由的 path 仅写名称,不写 “/”,如果希望是另外的地址,则直接以 “/” 开头。

{
        path: "/lifetools",
        name: "lifetools",
        component: () =>
            import(/* webpackChunkName: "LifeTools" */ "@/views/LifeTools.vue"),
        children: [
            {
                path: "caculator", // 最终生成路由   /lifetools/caculator
                                // path: "/caculator", // 最终生成路由   /caculator
                name: "Caculator",
                component: () =>
                    import(/* webpackChunkName: "CodeTools" */ "@/views/Caculator.vue"),
            },
]

摘自官方文档:

 

 

posted @ 2023-02-03 14:01  蓓蕾心晴  阅读(309)  评论(0编辑  收藏  举报