menu.vue
2.53 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
<template>
<div class="menu-box">
<el-menu :default-active="activeIndex" class="el-menu-hideafter" mode="horizontal" @select="handleSelect">
<el-menu-item index="/show" >
<template slot="title"><div class="menu-title"><i class="gy-icon-shouye menu-icon"></i>首页</div></template>
</el-menu-item>
<el-menu-item v-for="(fristmenu,index) in permission_routers" :key="index" :index="fristmenu.path" v-if="fristmenu.children.length < 1">
<i :class="[fristmenu.meta.icon,'menu-icon']"></i>{{fristmenu.name}}
</el-menu-item>
<el-submenu v-for="(fristmenu,index) in permission_routers" :key="index" v-if="fristmenu.children.length > 0" :index="fristmenu.path" >
<template slot="title"><i :class="[fristmenu.meta.icon,'menu-icon']"></i>{{fristmenu.name}}</template>
<el-menu-item :class="{'dark-submenu':theme=='dark','white-submenu':theme == 'white'}" v-for="(twomenu,index) in fristmenu.children" :key="index" :index="twomenu.path" v-if="twomenu.children.length < 1">{{twomenu.name}}</el-menu-item>
<el-submenu v-for="(twomenu,index) in fristmenu.children" :key="index" :index="twomenu.path" v-if="twomenu.children.length > 0">
<template slot="title">{{twomenu.name}}</template>
<el-menu-item v-for="(threemenu,index) in twomenu.children" :key="index" :index="threemenu.path">{{threemenu.name}}</el-menu-item>
</el-submenu>
</el-submenu>
</el-menu>
</div>
</template>
<script>
import { mapGetters,mapState} from 'vuex'
import Vue from 'vue'
export default {
data() {
return {
activeIndex: '/home',
};
},
methods: {
handleSelect(key, keyPath) {
sessionStorage.setItem('menu',key);
this.$router.push(key);
},
selcurIndex(data){
this.activeIndex = data
},
},
computed: {
...mapState(['theme']),
...mapGetters([
'permission_routers',
]),
},
created(){
console.log(this.theme)
let menu = sessionStorage.getItem('menu');
if(menu) {
this.activeIndex = sessionStorage.getItem('menu');
this.handleSelect(this.activeIndex);
} else {
this.activeIndex = '/show'
this.handleSelect(this.activeIndex);
}
},
watch:{
theme(val){
}
// '$route':'changeRouter'
}
};
</script>
<style lang="stylus" scoped>
.menu-box {
height 60px
text-align center
overflow hidden
.menu-title{
}
}
</style>