TabCustomer.vue
2.17 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
111
112
113
114
<template>
<div class="tab" v-if="data.length > 0">
<!-- 样式占位符-->
<div class="canvas-tab flex">
<template v-for="(i, index) in data">
<div @click="click(index)" :class="['item', `${tabIndex == index ? 'active-' + index : ''}`]" :key="index"></div>
</template>
</div>
<div class="canvas-place-tab flex placeholder">
<template v-for="(i, index) in data">
<div @click="click(index)" :class="['item', 'text-center', `${tabIndex == index ? 'active' : ''}`]" :key="index + 'i'">{{ i }}</div>
</template>
</div>
<slot></slot>
</div>
</template>
<script>
export default {
name: 'TabCustomer',
props: {
index: {
type: Number,
default: 0
},
list: {
type: Array,
default: () => {
return []
}
}
},
data() {
return {
data: this.list,
tabIndex: this.index
}
},
watch: {
index(n) {
this.tabIndex = n
},
list: {
handler(n) {
this.data = n
},
immediate: true,
deep:true
}
},
mounted() {},
methods: {
click(index) {
this.$emit('change', index)
}
}
}
</script>
<style scoped lang='scss'>
.tab {
height: auto;
box-shadow: 0px 3px 10px 0px rgba(223, 228, 234, 0.81);
border-radius: 4px;
position: relative;
background-color: #fff;
.canvas-tab {
width: 100%;
height: 50px;
box-sizing: border-box;
background-color: #EBEFF5;
.item {
width: 50%;
// transition: all 0.5s;
font-size: 14px;
}
.active-0 {
height: 0;
border-bottom: 50px solid #ffffff;
border-right: 10px solid transparent;
}
.active-1 {
height: 0;
border-bottom: 50px solid #ffffff;
border-left: 10px solid transparent;
}
}
.canvas-place-tab {
width: 100%;
height: 50px;
box-sizing: border-box;
font-size: 12px;
color: #333333;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 9;
.item {
color: #333333;
flex: 1;
transition: all 0.5s;
font-size: 14px;
}
.active {
color: #3975c6;
height: 50px;
}
}
}
</style>