lineHeader.vue
1.79 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
<template>
<div class="header">
<div>{{ title }}趋势</div>
<div class="times">
<div
:class="{
time: true,
active: index === activeIndex
}"
v-for="(item, index) in timeopts"
:key="index"
@click="handleClick(index)"
>
{{ item.label }}
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
activeIndex: 0,
timeopts: [
{ label: "近7日", value: 1 },
{ label: "本月", value: 2 },
{ label: "上月", value: 3 },
{ label: "近30日", value: 4 }
]
}
},
props: {
title: {
type: String,
default: "评估量趋势"
}
},
methods: {
handleClick(index) {
if (this.activeIndex != index) {
this.activeIndex = index
let data = this.timeopts[index]
this.$emit("handleClick", data, this.activeIndex, index)
}
}
}
}
</script>
<style scoped lang="scss">
.header {
display: flex;
align-items: center;
justify-content: space-between;
.times {
display: flex;
align-items: center;
border: 1px solid #dbdbdb;
border-radius: 2px;
box-sizing: border-box;
.time {
padding: 7.5px 18px;
line-height: 17px;
cursor: pointer;
color: #1d1d1d;
font-size: 12px;
font-weight: 400;
border-right: 1px solid #dbdbdb;
box-sizing: border-box;
}
.active {
color: #ffffff;
background: #2a58ad;
&:first-child {
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
}
&:last-child {
border-right: none;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
}
}
.time:last-child {
border-right: none;
}
}
}
</style>