element 动态导航渲染及数据案例

64 篇文章 1 订阅
11 篇文章 0 订阅

element 导航实现基于elemenet实现使用前请确保已成功引入

html 部分

<!--侧边栏菜单-->
      <el-menu background-color="inherit" text-color="#fff" active-text-color="#fff" unique-opened :collapse="isCollapse" :collapse-transition="false" router :default-active="activePath">
        <template v-for="item in menuList">
          <el-submenu :index="item.menuId" :key="item.menuId" v-if="!item.actionName">
            <!--一级菜单的模板区域-->
            <template slot="title">
              <!--图标-->
              <i :class="iconStyle(item.menuName)"></i>
              <!--文本-->
              <span>{{ item.menuName }}</span>
            </template>
            <!--二级菜单-->
            <el-menu-item :index="subItem.actionName" v-for="subItem in item.menuList" :key="subItem.menuId" @click="saveNavState(subItem.actionName)">
              <template slot="title">
                <!--图标-->
                <i class="el-icon-s-operation"></i>
                <!--文本-->
                <span>{{ subItem.menuName }}</span>
              </template>
            </el-menu-item>
          </el-submenu>

          <el-menu-item v-else :index="item.actionName" :key="item.menuId" @click="saveNavState(item.actionName)">
            <template slot="title">
              <!--图标-->
              <i class="el-icon-s-home" style="color:#fff"></i>
              <!--文本-->
              <span>{{ item.menuName }}</span>
            </template>
            <router-link :to="'/Main'" v-show="isCollapse"><i class="el-icon-s-home" style="color:#fff"></i></router-link>
          </el-menu-item>
        </template>
      </el-menu>

js 部分

  data() {
    return {
      menuList: [],
    }
  },
 created() {
// 引入本地json 数据
   var  goodsData = require( './data.json' )
     this.menuList = goodsData
  },

data 文件

[
  {
    "actionName":"Main",  
    "menuId": "QLJY_Main",
    "menuName": "首页",
   " parentMenuId": "BS_ROOT",
  "  webSiteId": "QLJY"
  },
  {
   " menuId": "QLJY_SysMGT",
    "menuList": [
        { 
            "actionName": "OrgMGT",
            "menuId": "QLJY_OrgMGT",
            "menuName": "组织管理",
            "parentMenuId": "QLJY_SysMGT",
            "webSiteId": "QLJY"
        },
        {
           "actionName": "RoleMGT",
            "menuId": "QLJY_RoleMGT",
           "menuName": "小姐姐啊",
            "parentMenuId": "QLJY_SysMGT",
           " webSiteId": "QLJY"
        }
    ],
   "menuName": "系统管理",
    "parentMenuId": "BS_ROOT",
    "webSiteId": "QLJY"
  }
]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小四是个处女座

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值