zoukankan      html  css  js  c++  java
  • vue+element的el-menu组件实现路由跳转及当前项的设置

    <el-menu router :default-active="$route.path" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" theme="dark">  
        <el-submenu index="1">  
            <template slot="title">  
                <i class="el-icon-location"></i>  
                <span>用户信息</span>  
            </template>  
            <el-menu-item-group>  
                <el-menu-item index="/user/account">账号信息</el-menu-item>  
                <el-menu-item index="/user/password">修改密码</el-menu-item>  
        </el-submenu>  
        <el-submenu index="2">  
                <template slot="title">  
                <i class="el-icon-location"></i>  
                <span>公司信息</span>  
            </template>  
            <el-menu-item-group>  
                <el-menu-item index="/company/userManager">用户管理</el-menu-item>  
                <el-menu-item index="/company/editUser">添加/编辑用户</el-menu-item>  
            </el-menu-item-group>  
            </el-submenu>  
    </el-menu>

    1.要实现路由跳转,先要在el-menu标签上添加router属性,然后只要在每个el-menu-item标签内的index属性设置一下url即可实现点击el-menu-item实现路由跳转。

    2.导航当前项,在el-menu标签中绑定  :default-active="$route.path",注意是绑定属性,不要忘了加“:”,当$route.path等于el-menu-item标签中的index属性值时则该item为当前项。

  • 相关阅读:
    相关分析[SDOI2017]
    排序[HEOI2016/TJOI2016]
    逆序对[AHOI2008]
    逆序对数列[HAOI2009]
    小Z的袜子「2009国家集训队」
    http抓包—Content-Type讲解
    mysql——leetcode问题记录
    linux--vi命令
    Linux—echo命令
    Linux—文件命令之touch命令
  • 原文地址:https://www.cnblogs.com/luyuefeng/p/8031468.html
Copyright © 2011-2022 走看看