|
1 | 1 | <template> |
2 | 2 | <view v-if="show" :style="{backgroundColor:backgroundColor,color:color}" class="uni-noticebar" @click="onClick"> |
3 | | - <view v-if="showClose === 'true' || showClose === true" class="uni-noticebar__close"> |
| 3 | + <view v-if="showClose" class="uni-noticebar__close"> |
4 | 4 | <uni-icon type="closefill" size="12" /> |
5 | 5 | </view> |
6 | 6 | <view :class="{'uni-noticebar--flex': scrollable || single || moreText}" class="uni-noticebar__content"> |
7 | | - <view v-if="showIcon === 'true' || showIcon === true" :style="{backgroundColor:backgroundColor,color:color}" class="uni-noticebar__content-icon"> |
| 7 | + <view v-if="showIcon" :style="{backgroundColor:backgroundColor,color:color}" class="uni-noticebar__content-icon"> |
8 | 8 | <uni-icon :color="color" type="sound" size="14" /> |
9 | 9 | </view> |
10 | 10 | <view :class="{'uni-noticebar--scrollable':scrollable,'uni-noticebar--single':!scrollable && (single || moreText)}" class="uni-noticebar__content-text"> |
11 | 11 | <view :id="elId" :style="{'animation': animation,'-webkit-animation': animation}" class="uni-noticebar__content-inner">{{ text }}</view> |
12 | 12 | </view> |
13 | | - <view v-if="showGetMore === 'true' || showGetMore === true" :style="{width:moreText ? '180upx' : '20px'}" class="uni-noticebar__content-more" @click="clickMore"> |
| 13 | + <view v-if="showGetMore" :style="{width:moreText ? '180upx' : '20px'}" class="uni-noticebar__content-more" @click="clickMore"> |
14 | 14 | <view v-if="moreText" class="uni-noticebar__content-more-text">{{ moreText }}</view> |
15 | 15 | <uni-icon type="arrowright" size="14" /> |
16 | 16 | </view> |
|
47 | 47 | default: '#de8c17' |
48 | 48 | }, |
49 | 49 | single: { // 是否单行 |
50 | | - type: [String, Boolean], |
| 50 | + type: Boolean, |
51 | 51 | default: false |
52 | 52 | }, |
53 | 53 | scrollable: { // 是否滚动,添加后控制单行效果取消 |
54 | | - type: [String, Boolean], |
| 54 | + type: Boolean, |
55 | 55 | default: false |
56 | 56 | }, |
57 | 57 | showIcon: { // 是否显示左侧icon |
58 | | - type: [String, Boolean], |
| 58 | + type: Boolean, |
59 | 59 | default: false |
60 | 60 | }, |
61 | 61 | showGetMore: { // 是否显示右侧查看更多 |
62 | | - type: [String, Boolean], |
| 62 | + type: Boolean, |
63 | 63 | default: false |
64 | 64 | }, |
65 | 65 | showClose: { // 是否显示左侧关闭按钮 |
66 | | - type: [String, Boolean], |
| 66 | + type: Boolean, |
67 | 67 | default: false |
68 | 68 | } |
69 | 69 | }, |
|
98 | 98 | }, |
99 | 99 | onClick(e) { |
100 | 100 | let clientX = e.touches ? (e.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX) : e.detail.clientX |
101 | | - if (uni.upx2px(48) + 12 > clientX && (String(this.showClose) === 'true')) { |
| 101 | + if (uni.upx2px(48) + 12 > clientX && this.showClose) { |
102 | 102 | this.show = false |
103 | 103 | this.$emit('close') |
104 | 104 | } |
105 | 105 | this.$emit('click') |
106 | 106 | }, |
107 | 107 | setAnimation() { |
108 | | - if (this.scrollable === false || this.scrollable === 'false') { |
| 108 | + if (!this.scrollable) { |
109 | 109 | return |
110 | 110 | } |
111 | 111 | // #ifdef MP-TOUTIAO |
|
0 commit comments