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
| <template>
| <scroll-view class="tag" scroll-x>
| <view class="tag_list">
| <view v-for="(item, index) in TagList"
| :key="index"
| :class="{'tag_item': true, 'tagActive': index == activeId}"
| @click="change(item, index)">
| <text>{{item.name}}</text>
| <text v-if="isShow && item.num">({{item.num}})</text>
| </view>
| </view>
| </scroll-view>
| </template>
|
| <script>
| export default {
| name: "LabelSelection",
| props: {
| TagList: Array,
| isShow: Boolean
| },
| data() {
| return {
| activeId: 0
| };
| },
| methods: {
| change(item, index) {
| if (this.activeId !== index) {
| this.activeId = index
| this.$emit('change', item.id)
| }
| }
| },
| watch: {
| // TagList: {
| // immediate: true,
| // handler(news, old) {
| // let list = news
| // if (list && list.length !== 0) {
| // this.activeId = list[0].id
| // }
| // }
| // }
| }
| }
| </script>
|
| <style lang="scss" scoped>
| .tag::-webkit-scrollbar {
| width: 0 !important;
| }
| .tag::-webkit-scrollbar {
| width: 0 !important;
| height: 0;
| }
| .tag {
| width: 100%;
| padding: 5rpx 0;
| box-sizing: border-box;
| .tag_list {
| width: 100%;
| display: flex;
| align-items: center;
| flex-wrap: nowrap;
| .tagActive {
| background: $nav-color !important;
| text {
| color: #FFFFFF !important;
| }
| }
| .tag_item {
| min-width: 120rpx;
| padding: 14rpx 24rpx;
| border-radius: 26rpx;
| text-align: center;
| flex-shrink: 0;
| margin-right: 20rpx;
| border: 1rpx solid #CCCCCC;
| font-size: 26rpx;
| font-weight: 400;
| line-height: 26rpx;
| color: #555555;
| }
| }
| }
| </style>
|
|