menu.vue
1.96 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
<template>
<div class="box">
<el-menu
:default-active="activemenu"
class="el-menu-vertical-demo"
:collapse="isCollapse"
@select="handleSelect"
>
<el-submenu index="1">
<template slot="title">
<i class="el-icon-location"></i>
<span slot="title">首页</span>
</template>
<el-menu-item index="/trficcshow">
<i class="el-icon-location"></i>交通展示
</el-menu-item>
<el-menu-item index="/behaviorshow">
<i class="el-icon-location"></i>综治展示
</el-menu-item>
</el-submenu>
<el-submenu v-for="(fristmenu,index) in permission_routers" :index="fristmenu.path" :key="index">
<template slot="title">
<i :class="fristmenu.meta.icon"></i>
<span slot="title">{{fristmenu.name}}</span>
</template>
<el-menu-item v-for="(twomenu,index) in fristmenu.children" :key="index" :index="twomenu.path">
<i :class="twomenu.meta.icon"></i>{{twomenu.name}}
</el-menu-item>
</el-submenu>
</el-menu>
</div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
export default {
data() {
return {
full: false,
isCollapse: false,
activemenu: "/",
topbar:[]
};
},
methods: {
handleSelect(key, keyPath) {
this.$router.push(key);
localStorage.setItem("curmenu", key);
this.activemenu = key
}
},
computed: {
...mapGetters(["permission_routers"])
},
created() {
let activemenu = localStorage.getItem("curmenu");
if (activemenu) {
this.activemenu = activemenu;
this.$router.push(activemenu);
} else {
this.$router.push('/');
this.activemenu = '/';
}
},
watch:{
$route(t, f){
let obj = {
name:f.name,
path:f.path,
icon:f.meta.icon
}
this.$emit("setTopBar",obj)
}
}
};
</script>
<style lang="stylus" scoped>
.box{
height 100%;
}
</style>