InnerTab.vue
1.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
<template>
<div class="tab-box">
<div class="tab-item-box" :style="{ width: width + 'vw' }">
<div :class="['tab-item', tabActive == index ? 'tab-item-active' : '']" :style="{ 'padding-left': itemPadding + 'vw', 'padding-right': itemPadding + 'vw' }" v-for="(item, index) in list" :key="index" @click="changeTab(index)">
{{ item }}
</div>
</div>
</div>
</template>
<script>
export default {
name: 'InnerTab',
props: {
list: {
type: Array,
default: () => []
},
width: Number,
itemPadding: Number
},
data() {
return {
tabActive: 0
}
},
mounted() {},
methods: {
// 切换tab
changeTab(index) {
this.tabActive = index
this.$emit('changeTab', index)
}
}
}
</script>
<style lang="scss" scoped>
.tab-box {
.tab-item-box {
display: flex;
margin: 0 auto;
height: 2.67vh;
background: #072545;
line-height: 2.67vh;
cursor: pointer;
.tab-item {
text-align: center;
box-sizing: border-box;
font-weight: 400;
font-size: 12px;
line-height: 2.67vh;
color: #c9c9c9;
&-active {
color: #5894ff;
background-image: -webkit-linear-gradient(left, #24d8ff, #7787ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
line-height: 2.22vh;
font-weight: 600;
border: 2px solid;
border-image: linear-gradient(90deg, #074989, #30dcff, #074989) 1;
box-sizing: border-box;
}
}
}
}
</style>