侧边栏路由结构如下(以下只做举例):
{
path: '/首页',// 第一层路由
name: '首页',
meta: {
name: '首页'
},
component: Layout,
children: [ // 第二层路由
{
path: '商品',
name: '商品',
component:GoodsIndex,// 注意,第二层这里的组件也要写,这个组件只为提供router-view
children: [ // 第三层路由
{
path: '商品详情',
name: '商品详情',
component: GoodsDetail,
},
]
}
]
}
重点来了,渲染不出来是因为第二层那里缺少一个router-view
容器,用一个组件专门用来渲染即可
GoodsIndex.vue
的内容:
<template>
<div>
<router-view />
</div>
</template>