index.vue
2.52 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
<div class="layout-header">
<el-header class="platform-head fixed-header">
<div class="header-middle">
<!-- menu -->
<el-menu
:default-active="activeIndex"
class="header-menu-wrapper"
background-color="#1d66f3"
text-color="#fff"
mode="horizontal"
@select="handleSelect"
>
<menus-item v-for="route in routes" :key="route.key" :item="route" />
</el-menu>
</div>
<div class="header-left">logo</div>
<div class="header-right">right</div>
</el-header>
</div>
</template>
<script>
import MenusItem from '../MenuItem'
export default {
name: 'GlobalHeader',
components: { MenusItem },
data() {
return {
activeIndex: '',
routes: [
{
key: 'home',
path: '/',
name: '首页'
},
{
key: 'analysis',
path: 'analysis',
name: '客流统计'
},
{
key: 'behavior',
path: 'behavior',
name: '人脸分析'
},
{
key: 'dataasis',
path: 'dataasis',
name: '数据分析'
},
{
key: 'manage',
path: 'manage',
name: '后台管理'
}
]
}
},
computed: {
activeMenu() {
const route = this.$route
const currRoute = this.routes.find(
item => route.path.indexOf(item.key) > -1
)
return (currRoute && '/' + currRoute.path) || '/'
}
},
mounted() {
// console.log('activeMenu', this.activeMenu)
},
methods: {
handleSelect(key) {
this.$router.push(key)
}
}
}
</script>
<style lang="scss" scoped>
.layout-header {
box-sizing: border-box;
flex: 0 0 auto;
}
.platform-head {
width: 100%;
background-color: #1d66f3;
color: #fff;
height: 60px;
line-height: 60px;
padding: 0 500px 0 364px;
overflow: hidden;
&.fixed-header {
position: fixed;
top: 0;
right: 0;
z-index: 9;
}
}
.header-middle {
position: relative;
float: left;
width: 100%;
height: 60px;
}
.header-menu-wrapper {
font-size: 16px;
color: #fff;
}
.header-left {
position: relative;
float: left;
width: 364px;
height: inherit;
left: -364px;
padding-left: 165px;
margin-left: -100%;
background: #1d66f3;
text-align: center;
}
.header-right {
position: relative;
float: left;
width: 500px;
height: inherit;
right: -500px;
margin-left: -500px;
background: #1d66f3;
text-align: center;
}
</style>