<template>
<el-container style="border: 1px solid #eee">
<el-aside width="220px" style="background-color: #ffffff">
<el-menu
default-active="1"
router
background-color="#FFFFFF"
text-color="#303133"
active-text-color="#409EFF"
>
<div v-for="(item, index) in menuList" :key="index">
<el-menu-item v-if="!item.childs" :index="item.routePath">
<i :class="item.iconClass"></i>
<span slot="title">{{ item.permissionName }}</span>
</el-menu-item>
<el-submenu :index="String(index)" v-if="item.childs">
<template slot="title">
<i :class="item.iconClass"></i>
<span>{{ item.permissionName }}</span>
</template>
<el-menu-item-group
v-for="(list, index) in item.childs"
:key="index"
>
<el-menu-item :index="list.routePath">
<i :class="list.iconClass"></i>
<span slot="title">{{ list.permissionName }}</span>
</el-menu-item>
</el-menu-item-group>
</el-submenu>
</div>
</el-menu>
</el-aside>
<el-main style="background-color: #ebeef5">
<router-view></router-view>
</el-main>
</el-container>
</template>
<script>
export default {
data() {
return {
menuList: [],
};
},
mounted() {
this.menuList = [
{
routePath: "/home",
permissionName: "首页",
iconClass:"el-icon-s-home",
},
{
routePath: "/dfcfh",
permissionName: "1",
iconClass:"el-icon-s-home",
},
{
routePath: "/pfcfh",
permissionName: "2",
},
{
routePath: "/zdt",
permissionName: "3",
},
{
permissionName: "4",
childs: [
{
routePath: "/pfcfh",
permissionName: "4-1",
},
{
routePath: "/zdt",
permissionName: "4-2",
},
],
},
];
},
};
</script>
element 动态菜单
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 背景 如上图所示: 菜单aaaa:url根据用户权限动态生成,路由形如/a/:b/xxxx,依赖参数b 参数 b:...
- 原文网址:https://www.cnblogs.com/wasbg/p/12696303.html[https:...
- https://blog.csdn.net/TCF_JingFeng/article/details/90679308
- 便于对用户权限进行控制,后台的菜单可以做成动态。在/src/layout/components/Sidebar/i...
- 在我开发的很多系统里面,包括Winform混合框架、Bootstrap开发框架等系列产品中,我都倾向于动态配置菜单...