Skip to content

Commit 0102ec8

Browse files
committed
update(uni-ui): 优化组件中 Boolean 类型的限定
1 parent 026541f commit 0102ec8

8 files changed

Lines changed: 28 additions & 28 deletions

File tree

‎components/uni-collapse-item/uni-collapse-item.vue‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
default: 0
3737
},
3838
disabled: { // 是否禁用
39-
type: [Boolean, String],
39+
type: Boolean,
4040
default: false
4141
},
4242
showAnimation: { // 是否显示动画
4343
type: Boolean,
4444
default: false
4545
},
4646
open: { // 是否展开
47-
type: [Boolean, String],
47+
type: Boolean,
4848
default: false
4949
},
5050
thumb: { // 缩略图
@@ -70,7 +70,7 @@
7070
this.isOpen = this.open
7171
this.nameSync = this.name ? this.name : this.collapse.childrens.length
7272
this.collapse.childrens.push(this)
73-
if (String(this.collapse.accordion) === 'true') {
73+
if (this.collapse.accordion) {
7474
if (this.isOpen) {
7575
let lastEl = this.collapse.childrens[this.collapse.childrens.length - 2]
7676
if (lastEl) {
@@ -101,7 +101,7 @@
101101
if (this.disabled) {
102102
return
103103
}
104-
if (String(this.collapse.accordion) === 'true') {
104+
if (this.collapse.accordion) {
105105
this.collapse.childrens.forEach(vm => {
106106
if (vm === this) {
107107
return

‎components/uni-collapse/uni-collapse.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
name: 'UniCollapse',
99
props: {
1010
accordion: { // 是否开启手风琴效果
11-
type: [Boolean, String],
11+
type: Boolean,
1212
default: false
1313
}
1414
},

‎components/uni-grid/uni-grid.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
default: 3
3131
},
3232
showOutBorder: { // 显示外边框
33-
type: [Boolean, String],
33+
type: Boolean,
3434
default: true
3535
},
3636
showBorder: { // 是否显示border,如果为false,showOutBorder无效
37-
type: [Boolean, String],
37+
type: Boolean,
3838
default: true
3939
}
4040
},

‎components/uni-nav-bar/uni-nav-bar.vue‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<view class="uni-navbar">
3-
<view :class="{'uni-navbar--fixed': !!fixed,'uni-navbar--shadow':!!border,'uni-navbar--border':!!border}" :style="{'background-color':backgroundColor}" class="uni-navbar__content">
3+
<view :class="{'uni-navbar--fixed': fixed,'uni-navbar--shadow':border,'uni-navbar--border':border}" :style="{'background-color':backgroundColor}" class="uni-navbar__content">
44
<uni-status-bar v-if="statusBar" />
55
<view :style="{color:color}" class="uni-navbar__header">
66
<view class="uni-navbar__header-btns" @tap="onClickLeft">
@@ -64,7 +64,7 @@
6464
default: ''
6565
},
6666
fixed: {
67-
type: [Boolean, String],
67+
type: Boolean,
6868
default: false
6969
},
7070
color: {
@@ -76,15 +76,15 @@
7676
default: '#FFFFFF'
7777
},
7878
statusBar: {
79-
type: [Boolean, String],
79+
type: Boolean,
8080
default: false
8181
},
8282
shadow: {
83-
type: [String, Boolean],
83+
type: Boolean,
8484
default: true
8585
},
8686
border: {
87-
type: [String, Boolean],
87+
type: Boolean,
8888
default: true
8989
}
9090
},

‎components/uni-notice-bar/uni-notice-bar.vue‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<template>
22
<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">
44
<uni-icon type="closefill" size="12" />
55
</view>
66
<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">
88
<uni-icon :color="color" type="sound" size="14" />
99
</view>
1010
<view :class="{'uni-noticebar--scrollable':scrollable,'uni-noticebar--single':!scrollable && (single || moreText)}" class="uni-noticebar__content-text">
1111
<view :id="elId" :style="{'animation': animation,'-webkit-animation': animation}" class="uni-noticebar__content-inner">{{ text }}</view>
1212
</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">
1414
<view v-if="moreText" class="uni-noticebar__content-more-text">{{ moreText }}</view>
1515
<uni-icon type="arrowright" size="14" />
1616
</view>
@@ -47,23 +47,23 @@
4747
default: '#de8c17'
4848
},
4949
single: { // 是否单行
50-
type: [String, Boolean],
50+
type: Boolean,
5151
default: false
5252
},
5353
scrollable: { // 是否滚动,添加后控制单行效果取消
54-
type: [String, Boolean],
54+
type: Boolean,
5555
default: false
5656
},
5757
showIcon: { // 是否显示左侧icon
58-
type: [String, Boolean],
58+
type: Boolean,
5959
default: false
6060
},
6161
showGetMore: { // 是否显示右侧查看更多
62-
type: [String, Boolean],
62+
type: Boolean,
6363
default: false
6464
},
6565
showClose: { // 是否显示左侧关闭按钮
66-
type: [String, Boolean],
66+
type: Boolean,
6767
default: false
6868
}
6969
},
@@ -98,14 +98,14 @@
9898
},
9999
onClick(e) {
100100
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) {
102102
this.show = false
103103
this.$emit('close')
104104
}
105105
this.$emit('click')
106106
},
107107
setAnimation() {
108-
if (this.scrollable === false || this.scrollable === 'false') {
108+
if (!this.scrollable) {
109109
return
110110
}
111111
// #ifdef MP-TOUTIAO

‎components/uni-pagination/uni-pagination.vue‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<view class="uni-pagination">
33
<view class="uni-pagination__btns">
44
<view :class="['uni-pagination__btn',{'uni-pagination--disabled':currentIndex === 1}]" :hover-class="currentIndex === 1 ? '' : 'uni-pagination--hover'" :hover-start-time="20" :hover-stay-time="70" @click="clickLeft">
5-
<template v-if="showIcon===true || showIcon === 'true'">
5+
<template v-if="showIcon">
66
<uni-icon color="#000" size="20" type="arrowleft" />
77
</template>
88
<template v-else>
99
{{ prevText }}
1010
</template>
1111
</view>
1212
<view :class="['uni-pagination__btn',{'uni-pagination--disabled':currentIndex === maxPage}]" :hover-class="currentIndex === maxPage ? '' : 'uni-pagination--hover'" :hover-start-time="20" :hover-stay-time="70" @click="clickRight">
13-
<template v-if="showIcon===true || showIcon === 'true'">
13+
<template v-if="showIcon">
1414
<uni-icon color="#000" size="20" type="arrowright" />
1515
</template>
1616
<template v-else>
@@ -53,7 +53,7 @@
5353
default: 10
5454
},
5555
showIcon: { // 是否以 icon 形式展示按钮
56-
type: [Boolean, String],
56+
type: Boolean,
5757
default: false
5858
}
5959
},

‎components/uni-rate/uni-rate.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
props: {
2020
isFill: {
2121
// 星星的类型,是否镂空
22-
type: [Boolean, String],
22+
type: Boolean,
2323
default: true
2424
},
2525
color: {
@@ -54,7 +54,7 @@
5454
},
5555
disabled: {
5656
// 是否可点击
57-
type: [Boolean, String],
57+
type: Boolean,
5858
default: false
5959
}
6060
},

‎components/uni-swipe-action/uni-swipe-action.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
this.endMove()
161161
},
162162
endMove() {
163-
if (this.direction === 'Y' || this.disabled === true) {
163+
if (this.direction === 'Y' || this.disabled) {
164164
this.direction = ''
165165
return
166166
}

0 commit comments

Comments
 (0)