Vue结合element-ui实现路由嵌套

Vue结合element-ui实现路由嵌套

:router="true"  //开启index路由
            <el-menu
              default-active="/"
              background-color="#545c64"
              class="el-menu"
              active-text-color="#fff"
              text-color="#ddd"
              :router="true"  //开启index路由
              >
              <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"},
    //   {path: "order",component: Order,name:"order"},
    //   {path: "user",component: User,name: "user"},
    //   {path: "merchant/detail",component: MerchantDetail,name: "merchant_detail"},
    ]
  },
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"},
            //   {path: "order",component: Order,name:"order"},
            //   {path: "user",component: User,name: "user"},
            //   {path: "merchant/detail",component: MerchantDetail,name: "merchant_detail"},
            ]
          },
    ]
})

// 导出
export default router;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值