Menu.vue
2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
<div class="Navs">
<el-menu
:default-active="activeMenu"
class="el-menu-vertical-demo"
:collapse="true"
router
>
<el-menu-item index="/homePage">
<i class="el-icon-menu"></i>
<span>首页</span>
<!-- <span slot="title">首页</span> -->
</el-menu-item>
<div v-for="v in navList" :key="v.id">
<template v-if="v.children && v.children.length">
<el-submenu :index="v.path">
<template slot="title">
<i class="el-icon-location"></i>
<span slot="title">{{ v.fullName }}</span>
</template>
<el-menu-item-group>
<span slot="title">分组一</span>
<el-menu-item
:index="item.path"
v-for="item in v.children"
:key="item.id"
>{{ item.fullName }}</el-menu-item
>
</el-menu-item-group>
</el-submenu>
</template>
<template v-else>
<el-menu-item :index="v.path">
<i class="el-icon-menu"></i>
<span>{{ v.fullName }}</span>
</el-menu-item>
</template>
</div>
</el-menu>
</div>
</template>
<script>
export default {
name: "Navs",
data() {
return {
navList: "",
};
},
mounted() {
this.navList = this.$store.state.user.menuList;
},
computed: {
// 默认激活的菜单
activeMenu() {
console.log("activeMenu", this.$route.path);
return this.$route.path;
},
},
};
</script>
<style scoped lang="scss">
.Navs {
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 200px;
min-height: 400px;
}
:deep(.el-menu--collapse) {
width: 100%;
}
.el-menu-item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
line-height: 30px;
color: #fff;
&.is-active {
color: #1890ff;
background-color: #dfdada34;
}
span {
height: 30px;
width: 100%;
overflow: unset;
visibility: unset;
}
&:hover {
background-color: #dfdada56;
}
}
:deep(.el-menu) {
background-color: transparent;
border-right: unset;
.el-submenu__title {
display: flex;
flex-direction: column;
align-items: center;
line-height: 30px;
justify-content: center;
color: #fff;
&:hover {
background-color: #dfdada56;
}
}
i {
color: #fff;
}
.el-submenu__icon-arrow.el-icon-arrow-right {
display: none;
}
}
}
</style>