[bugfix] Stepper: disabled not work (#709)

This commit is contained in:
neverland 2018-10-08 21:47:38 +08:00 committed by GitHub
parent 1d72fd6ad5
commit 8ed16151f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -31,6 +31,16 @@ VantComponent({
}
},
computed: {
minusDisabled() {
return this.data.disabled || this.data.value <= this.data.min;
},
plusDisabled() {
return this.data.disabled || this.data.value >= this.data.max;
}
},
created() {
this.setData({
value: this.range(this.data.value)
@ -49,7 +59,7 @@ VantComponent({
},
onChange(type) {
if (this[`${type}Disabled`]) {
if (this.data[`${type}Disabled`]) {
this.$emit('overlimit', type);
return;
}

View File

@ -1,6 +1,6 @@
<view class="van-stepper custom-class">
<view
class="minus-class van-stepper__minus {{ disabled || value <= min ? 'van-stepper__minus--disabled' : '' }}"
class="minus-class van-stepper__minus {{ minusDisabled ? 'van-stepper__minus--disabled' : '' }}"
bind:tap="onMinus"
/>
<input
@ -12,7 +12,7 @@
bind:blur="onBlur"
/>
<view
class="plus-class van-stepper__plus {{ disabled || value >= max ? 'van-stepper__plus--disabled' : '' }}"
class="plus-class van-stepper__plus {{ plusDisabled ? 'van-stepper__plus--disabled' : '' }}"
bind:tap="onPlus"
/>
</view>