Skip to content

Commit

Permalink
Zw3639 master (umicro#476)
Browse files Browse the repository at this point in the history
* u-rate修改了选择的bug

* u-rate增加了readonly属性,不同于disabled,只读情况下不修改样式

* bugfix:调整rate,添加readonly属性

Co-authored-by: jamway <zw3639@qq.com>
  • Loading branch information
BeiQiaoT and zw3639 committed Apr 3, 2022
1 parent f21ad90 commit 00f942e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
20 changes: 14 additions & 6 deletions pages/componentsA/rate/rate.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<text class="u-demo-block__title">自定义选中星星数量</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-rate
<u-rate
size="20"
v-model="value"
@change="change"
Expand All @@ -32,15 +32,23 @@
<text class="u-demo-block__title">是否禁用评分</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate size="20" :disabled="true"></u-rate>
<u-rate size="20" disabled></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否只读评分</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate size="20" readonly></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义选中星星颜色</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
<u-rate
size="20"
v-model="activeColorValue"
activeColor="#2979ff"
Expand All @@ -52,7 +60,7 @@
<text class="u-demo-block__title">自定义未选中星星颜色</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
<u-rate
size="20"
v-model="value1"
inactiveColor="#2979ff"
Expand Down Expand Up @@ -80,7 +88,7 @@
<text class="u-demo-block__title">是否允许半星</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
<u-rate
size="20"
v-model="HalfValue"
:allowHalf="true"
Expand All @@ -93,7 +101,7 @@
<text class="u-demo-block__title">自定义选中的图标</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
<u-rate
size="20"
v-model="activeIconValue"
inactiveIcon="heart"
Expand Down
5 changes: 5 additions & 0 deletions uni_modules/uview-ui/components/u-rate/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export default {
type: Boolean,
default: uni.$u.props.rate.disabled
},
// 是否只读
readonly: {
type: Boolean,
default: uni.$u.props.rate.readonly
},
// 星星的大小,单位px
size: {
type: [String, Number],
Expand Down
3 changes: 2 additions & 1 deletion uni_modules/uview-ui/components/u-rate/u-rate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
* @property {String | Number} value 用于v-model双向绑定选中的星星数量 (默认 1 )
* @property {String | Number} count 最多可选的星星数量 (默认 5 )
* @property {Boolean} disabled 是否禁止用户操作 (默认 false )
* @property {Boolean} readonly 是否只读 (默认 false )
* @property {String | Number} size 星星的大小,单位px (默认 18 )
* @property {String} inactiveColor 未选中星星的颜色 (默认 '#b2b2b2' )
* @property {String} activeColor 选中的星星颜色 (默认 '#FA3534' )
Expand Down Expand Up @@ -206,7 +207,7 @@
},
// 获取当前激活的评分图标
getActiveIndex(x,isClick = false) {
if (this.disabled) {
if (this.disabled || this.readonly) {
return;
}
// 判断当前操作的点的x坐标值,是否在允许的边界范围内
Expand Down

0 comments on commit 00f942e

Please sign in to comment.