feat(Stepper): add disablePlus & disableMinus props (#2457)

This commit is contained in:
Jake 2019-12-04 16:50:42 +08:00 committed by rex
parent d4f6406390
commit baac222b2f
3 changed files with 9 additions and 5 deletions

View File

@ -125,6 +125,8 @@ Page({
| show-plus | 是否显示增加按钮 | *boolean* | `true` | - | | show-plus | 是否显示增加按钮 | *boolean* | `true` | - |
| show-minus | 是否显示减少按钮 | *boolean* | `true` | - | | show-minus | 是否显示减少按钮 | *boolean* | `true` | - |
| decimal-length | 固定显示的小数位数 | *number* | - | - | | decimal-length | 固定显示的小数位数 | *number* | - | - |
| disable-plus | 是否禁用增加按钮 | *boolean* | - | - |
| disable-minus | 是否禁用减少按钮 | *boolean* | - | - |
### Events ### Events

View File

@ -47,7 +47,9 @@ VantComponent({
showMinus: { showMinus: {
type: Boolean, type: Boolean,
value: true value: true
} },
disablePlus: Boolean,
disableMinus: Boolean
}, },
watch: { watch: {
@ -92,10 +94,10 @@ VantComponent({
methods: { methods: {
isDisabled(type: string) { isDisabled(type: string) {
if (type === 'plus') { if (type === 'plus') {
return this.data.disabled || this.data.value >= this.data.max; return this.data.disabled || this.data.disablePlus || this.data.value >= this.data.max;
} }
return this.data.disabled || this.data.value <= this.data.min; return this.data.disabled || this.data.disableMinus || this.data.value <= this.data.min;
}, },
onFocus(event: Weapp.Event) { onFocus(event: Weapp.Event) {

View File

@ -5,7 +5,7 @@
wx:if="{{ showMinus }}" wx:if="{{ showMinus }}"
data-type="minus" data-type="minus"
style="{{ buttonStyle }}" style="{{ buttonStyle }}"
class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || value <= min }) }}" class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || disableMinus || value <= min }) }}"
hover-class="van-stepper__minus--hover" hover-class="van-stepper__minus--hover"
hover-stay-time="70" hover-stay-time="70"
bind:tap="onTap" bind:tap="onTap"
@ -27,7 +27,7 @@
wx:if="{{ showPlus }}" wx:if="{{ showPlus }}"
data-type="plus" data-type="plus"
style="{{ buttonStyle }}" style="{{ buttonStyle }}"
class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || value >= max }) }}" class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || disablePlus || value >= max }) }}"
hover-class="van-stepper__plus--hover" hover-class="van-stepper__plus--hover"
hover-stay-time="70" hover-stay-time="70"
bind:tap="onTap" bind:tap="onTap"