mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-29 01:39:15 +08:00
feat(Rate): size prop support string (#1970)
This commit is contained in:
parent
17b13d5616
commit
ecfb244144
@ -3,7 +3,6 @@
|
|||||||
custom-class="van-rate"
|
custom-class="van-rate"
|
||||||
data-key="value1"
|
data-key="value1"
|
||||||
value="{{ value1 }}"
|
value="{{ value1 }}"
|
||||||
gutter="20px"
|
|
||||||
/>
|
/>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ Page({
|
|||||||
| name | 在表单内提交时的标识符 | *string* | - |
|
| name | 在表单内提交时的标识符 | *string* | - |
|
||||||
| value | 当前分值 | *number* | - |
|
| value | 当前分值 | *number* | - |
|
||||||
| count | 图标总数 | *number* | `5` |
|
| count | 图标总数 | *number* | `5` |
|
||||||
| size | 图标大小 `px` | *number* | `20` |
|
| size | 图标大小,默认单位为 `px` | *string \| number* | `20px` |
|
||||||
| gutter | 图标间距,默认单位为 `px` | *string \| number* | `4px` |
|
| gutter | 图标间距,默认单位为 `px` | *string \| number* | `4px` |
|
||||||
| color | 选中时的颜色 | *string* | `#ffd21e` |
|
| color | 选中时的颜色 | *string* | `#ffd21e` |
|
||||||
| void-color | 未选中时的颜色 | *string* | `#c7c7c7` |
|
| void-color | 未选中时的颜色 | *string* | `#c7c7c7` |
|
||||||
|
@ -13,8 +13,8 @@ VantComponent({
|
|||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
allowHalf: Boolean,
|
allowHalf: Boolean,
|
||||||
size: {
|
size: {
|
||||||
type: Number,
|
type: null,
|
||||||
value: 20
|
observer: 'setSizeWithUnit'
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -48,7 +48,8 @@ VantComponent({
|
|||||||
|
|
||||||
data: {
|
data: {
|
||||||
innerValue: 0,
|
innerValue: 0,
|
||||||
gutterWithUnit: undefined
|
gutterWithUnit: undefined,
|
||||||
|
sizeWithUnit: '20px'
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@ -60,6 +61,12 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
setSizeWithUnit(val) {
|
||||||
|
this.set({
|
||||||
|
sizeWithUnit: addUnit(val)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
setGutterWithUnit(val) {
|
setGutterWithUnit(val) {
|
||||||
this.set({
|
this.set({
|
||||||
gutterWithUnit: addUnit(val)
|
gutterWithUnit: addUnit(val)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
class="van-rate__item"
|
class="van-rate__item"
|
||||||
wx:for="{{ count }}"
|
wx:for="{{ count }}"
|
||||||
wx:key="index"
|
wx:key="index"
|
||||||
style="font-size: {{ size }}px;padding-right: {{ index !== count - 1 ? gutterWithUnit : '' }}"
|
style="font-size: {{ sizeWithUnit }};padding-right: {{ index !== count - 1 ? gutterWithUnit : '' }}"
|
||||||
>
|
>
|
||||||
<van-icon
|
<van-icon
|
||||||
name="{{ index + 1 <= innerValue ? icon : voidIcon }}"
|
name="{{ index + 1 <= innerValue ? icon : voidIcon }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user