public_switching.vue
1.1 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
<template>
<view class="public_switching" :style="{'grid-template-columns': `repeat(${option.length}, 1fr)`}">
<view
@click="selected(item)"
:class="{'public_switching-i': true, 'public_switching-i-c': item.value === current} "
v-for="item in option"
:key="item.value">{{ item.lable }}</view>
</view>
</template>
<script>
export default {
name:"public_switching",
props: {
current: {
type: [String, Number],
default: ''
},
option: {
type: [Array],
default: () => []
}
},
data() {
return {
};
},
methods: {
selected(item) {
this.$emit('change', item.value)
}
}
}
</script>
<style lang="scss" scoped>
.public_switching{
display: grid;
padding: 20rpx 0;
.public_switching-i{
flex-grow: 1;
text-align: center;
color: #F8F8F8;
}
.public_switching-i-c{
color: #F8F8F8;
position: relative;
&::before{
position: absolute;
content: '';
width: 38rpx;
background-color: #fff;
height: 4rpx;
bottom: -20rpx;
left: 50%;
transform: translateX(-50%);
}
}
}
</style>