Vue结合element-ui实现路由嵌套
:router="true"
<el-menu
default-active="/"
background-color="#545c64"
class="el-menu"
active-text-color="#fff"
text-color="#ddd"
:router="true"
>
<el-menu-item index="/">
<i class="el-icon-s-home"></i>
<span slot="title">首页</span>
</el-menu-item>
<el-menu-item index="/merchant">
<i class="el-icon-menu"></i>
<span slot="title">商家</span>
</el-menu-item>
<el-menu-item index="/user">
<i class="el-icon-user-solid"></i>
<span slot="title">用户</span>
</el-menu-item>
<el-menu-item index="/order">
<i class="el-icon-s-order"></i>
<span slot="title">订单</span>
</el-menu-item>
</el-menu>
显示切换界面
<router-view></router-view>
<el-container>
<!-- 切换显示界面 -->
<el-main class="main">
<router-view></router-view>
</el-main>
<el-footer class="footer">这是Footer</el-footer>
</el-container>
{
path: "/multiRoute",
component: MultiRouteView,
children: [
{path: "",component: Index,name:"index"},
{path: "merchant",component: Merchant,name: "merchant"},
]
},
import VueRouter from 'vue-router'
import Vue from "vue"
import FrameView from "./components/FrameView"
import LoginView from "./components/LoginView"
import LabelingView from "./components/LabelingView"
import AlgoProcessView from "./components/AlgoProcessView"
import MultiRouteView from "./components/MultiRouteView"
import Index from './components/index'
import Merchant from './components/Merchant'
Vue.use(VueRouter)
const router = new VueRouter({
routes:[
{
path:'/',
component:LabelingView,
name:"LabelingView"
},
{
path:'/frame',
component:FrameView,
name:"FrameView"
},
{
path:'/login',
component:LoginView,
name:"LoginView"
},
{
path:'/AlgoProcess',
component:AlgoProcessView,
name:"AlgoProcessView"
},
{
path: "/multiRoute",
component: MultiRouteView,
children: [
{path: "",component: Index,name:"index"},
{path: "merchant",component: Merchant,name: "merchant"},
]
},
]
})
export default router;