header-box.vue
2.51 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
<template>
<div class="layout-header-box">
<div class="header-left">
<slot name="left">
<i class="icon icon-back go-back-btn" @click="goBack"></i>
</slot>
</div>
<transition name="header-title">
<div class="header-title" v-show="showTitle">
<slot name="title">
{{yoho.title}}
</slot>
</div>
</transition>
<div class="header-right">
<slot name="right"></slot>
</div>
</div>
</template>
<script>
import {mapState} from 'vuex';
export default {
name: 'HeaderBox',
props: {
autoHide: Boolean,
className: [String, Object, Array]
},
computed: {
...mapState(['yoho'])
},
data() {
return {
showTitle: !this.autoHide
};
},
methods: {
goBack() {
this.$yoRouter.goBack(-1);
},
switchBase() {
this.showTitle = false;
},
switchNormal() {
this.showTitle = true;
}
}
};
</script>
<style lang="scss">
@import "~scss/variable.scss";
.layout-header-box {
position: relative;
height: $header-height;
font-size: $header-font-size;
padding: 0 20px;
width: 100%;
.icon {
vertical-align: middle;
display: inline-block;
width: 80px;
height: 100%;
line-height: $header-height;
font-size: $header-font-size;
&.icon-back {
font-size: 64px;
}
}
.header-left,
.header-right {
z-index: 2;
position: absolute;
min-width: 80px;
}
.header-left {
left: 20px;
top: 0;
}
.header-right {
text-align: right;
right: 20px;
top: 0;
}
.header-title {
position: absolute;
z-index: 1;
background-color: #fff;
left: 0;
top: 0;
right: 0;
bottom: 0;
text-align: center;
line-height: $header-height;
font-size: 17PX;
font-weight: bold;
color: #000;
letter-spacing: -0.41px;
border-bottom: solid 1px #eee;
font-family: HiraginoSansGB-W6, PingFang SC, Heiti SC, HelveticaNeue, Tahoma, Arial;
}
}
.header-title-enter-active,
.header-title-leave-active {
transition: opacity 0.2s ease-in-out;
}
.header-title-enter,
.header-title-leave-to {
opacity: 0;
}
.header-title-enter-to,
.header-title-leave {
opacity: 1;
}
</style>