Tab.vue
1.41 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
<template>
<div class="tab-box">
<div class="tab-item-box" :style="{ width: width + 'vw' }">
<div :class="['tab-item', tabActive == index ? 'tab-item-active' : '']" :style="{ width: (itemWidth) + 'vw','padding-left': paddingWidth + 'vw','padding-right': paddingWidth + 'vw' }" v-for="(item, index) in list" :key="index" @click="changeTab(index)">
{{ item }}
</div>
</div>
</div>
</template>
<script>
export default {
name: 'Tab',
props: {
list: {
type: Array,
default: () => []
},
width: Number,
itemWidth: Number,
paddingWidth: Number
},
data() {
return {
tabActive: 0
}
},
mounted() {},
methods: {
// 切换tab
changeTab(index) {
this.tabActive = index
this.$emit('changeTab', index)
}
}
}
</script>
<style lang="scss" scoped>
.tab-box {
margin: 0 auto;
.tab-item-box {
display: flex;
padding: 0.44vh 0.28vw;
border: 2px solid;
border-image: linear-gradient(90deg, #074989, #30dcff, #074989) 1;
background-image: linear-gradient(180deg, #001948 0%, #00223c 99%);
cursor: pointer;
.tab-item {
padding: 0.56vh 0;
text-align: center;
box-sizing: border-box;
font-weight: 400;
font-size: 16px;
color: #ffffffbf;
&-active {
background-image: linear-gradient(270deg, #6578ff 0%, #079ff1 100%);
color: #ffffff;
}
}
}
}
</style>