vue实现elementUI的左侧导航栏,右侧动态调用路由并解决导航栏高亮问题

原因:没有高亮是因为没有激活导航栏的item
1、首先注册需要跳转的router

{
            path: "/home",
            name: "Home",
            component: Home,
            children: [
                {
                    path: '/index',
                    component: () => import('../components/main/Index.vue')
                },
                {
                    path: '/week',
                    component: () => import('../components/meetingOrder/week.vue')
                },
                {
                    path: '/quick',
                    component: () => import('../components/meetingOrder/quick.vue')
                },
                {
                    path: '/day',
                    component: () => import('../components/meetingOrder/day.vue')
                }
            ]
        },

2、使用导航栏的default-active属性,默认为第一个打开的router,之后在需要每个item中使用index="/path",path为路由的地址。一定要加上“/

 <el-menu
                        default-active="1"
                        class="el-menu-vertical-demo"
                        unique-opened
                        menu-trigger="hover"
                        background-color="#545c64"
                        text-color="#fff"
                        active-text-color="orange"
                        :collapse="isCollapse"
                        :collapse-transition="false"
                        :default-active="activePath"
                        router>
                    <el-menu-item index="/index">
                        <i class="el-icon-menu"></i>
                        <span>主页</span>
                    </el-menu-item>
                    <el-submenu index="2">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>会议预约</span>
                        </template>
                        <el-menu-item index="/quick" >快速预定</el-menu-item>
                        <el-menu-item index="/day" >日历预定</el-menu-item>
                        <el-menu-item index="/week" >周历预定</el-menu-item>
                    </el-submenu>

3、在主体部分使用router-view

 <!--内容区-->
            <el-main>
                <router-view></router-view>
            </el-main>

4、大功告成!

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值