header.vue
1.67 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
<template>
<el-header class="layout-header">
<div class="left">
<img class="logo" src="/img/logo.svg" />
<span class="title">EAGLE WEB TOOLKIT</span>
</div>
<el-menu :default-active="activeMenu" mode="horizontal" @select="handleSelect">
<el-menu-item v-for="(data, index) in pages" :key="index" :index="data.meta.path">{{ data.meta.title }}</el-menu-item>
</el-menu>
</el-header>
</template>
<script>
import { pages } from '@/router/routes';
export default {
name: 'layoutHeader',
data() {
return {
activeMenu: '/index',
pages: pages.map((data, index) => {
const param = data.meta && data.meta.path ? {} : { meta: { title: `Page - ${index}`, path: '/index' } }
return { ...data, ...param }
})
}
},
created() {
const { matched = [] } = this.$route || {};
const route = matched[0] || {};
this.activeMenu = route.path || '/index';
},
methods: {
handleSelect(key) {
this.$router.push({ path: key });
}
}
}
</script>
<style lang="scss">
.layout-header {
position: fixed;
display: flex;
align-items: center;
justify-content: space-between;
background: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, .04) !important;
height: 60px;
width: 100%;
z-index: 10;
padding: 0 60px !important;
.el-menu.el-menu--horizontal {
border: 0;
}
.left {
display: flex;
align-items: center;
.logo {
height: 40px;
padding-right: 10px;
}
.title {
font-weight: bold;
font-size: 20px;
background-image: -webkit-linear-gradient(bottom, #333, #666);
background-clip: text;
-webkit-text-fill-color: transparent;
}
}
}
</style>