首页 > 解决方案 > 如何在两个不同的子路由中显示一个相同的 Vue 组件?

问题描述

const routes = [
{
    path: '/',
    component: LogInView
},
{
    path: '/store',
    component: Dashboard,
    children: [
        {
            path: '/products',
            component: ProductsView,
        },
    ]
},
{
    path: '/platform',
    component: Dashboard,
    children: [
        {
            path: '/products',
            component: ProductsView,
        },
    ]
},
{
    path: '/platform',
    component: Dashboard
} ]

假设,我正在尝试为&渲染Dashboard组件,并为&这两个路由渲染组件。但问题是当我点击或url 时,它是渲染组件。/store/platformProductView/store/products/platform/products

/store/products/platform/productsDashboard

标签: javascriptvue.jsroutingroutesvue-router

解决方案


您的代码的问题是您在每个子路由('/products')删除它之前写了一个斜杠


推荐阅读