javascript - 如何在两个不同的子路由中显示一个相同的 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
/platform
ProductView
/store/products
/platform/products
/store/products
/platform/products
Dashboard
解决方案
您的代码的问题是您在每个子路由('/products')删除它之前写了一个斜杠