header-box.vue
2.43 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
<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 brown-light" 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.$yoho.goBack({}, function() {}, function() {});
},
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: 0px 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;
color: #000000;
letter-spacing: -0.41px;
border-bottom: solid 1px #eee;
}
}
.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>