tip.vue
1.69 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
<template>
<transition name="fade">
<div class="tip" v-if="show">
{{text}}
<span class="close" v-if="hasClose" @click="closeTip"></span>
</div>
</transition>
</template>
<script>
export default {
name: 'navTitle',
props: {
text: {
type: String,
default: ''
},
show: {
type: Boolean,
default: false
},
hasClose: {
type: Boolean,
default: false
}
},
watch: {
show(item) {
if (item && !this.hasClose) {
setTimeout(() => {
this.$emit('change-tip-status', false);
}, 1000);
}
}
},
methods: {
closeTip() {
this.$emit('change-tip-status', false);
}
}
}
</script>
<style lang="scss" scoped>
.tip {
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 10px 20px;
position: fixed;
top: 0;
left: 0;
z-index: 2;
font-size: 14px;
width: 100%;
box-sizing: border-box;
text-align: center;
.close {
position: absolute;
width: 20px;
height: 20px;
line-height: 20px;
background: #666;
text-align: center;
right: 5px;
top: 50%;
margin-top: -10px;
border-radius: 50%;
border: 1px solid #fff;
cursor: pointer;
&:after {
content: "\00D7";
display: block;
color: #fff;
font-size: 16px;
}
}
}
.fade-enter-active, .fade-leave-active {
transition: opacity .2s;
}
.fade-enter, .fade-leave-to {
opacity: 0;
}
</style>