feat(Stepper): remove computed (#2000)

This commit is contained in:
neverland 2019-09-09 19:59:13 +08:00 committed by GitHub
parent a80accbcc2
commit 78681032b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View File

@ -39,16 +39,6 @@ VantComponent({
} }
}, },
computed: {
minusDisabled() {
return this.data.disabled || this.data.value <= this.data.min;
},
plusDisabled() {
return this.data.disabled || this.data.value >= this.data.max;
}
},
watch: { watch: {
value(value) { value(value) {
if (value === '') { if (value === '') {
@ -74,6 +64,14 @@ VantComponent({
}, },
methods: { methods: {
isDisabled(type: string) {
if (type === 'plus') {
return this.data.disabled || this.data.value >= this.data.max;
}
return this.data.disabled || this.data.value <= this.data.min;
},
onFocus(event: Weapp.Event) { onFocus(event: Weapp.Event) {
this.$emit('focus', event.detail); this.$emit('focus', event.detail);
}, },
@ -96,7 +94,7 @@ VantComponent({
}, },
onChange(type: string) { onChange(type: string) {
if (this.data[`${type}Disabled`]) { if (this.isDisabled(type)) {
this.$emit('overlimit', type); this.$emit('overlimit', type);
return; return;
} }

View File

@ -2,7 +2,7 @@
<view class="van-stepper custom-class"> <view class="van-stepper custom-class">
<view <view
class="minus-class {{ utils.bem('stepper__minus', { disabled: minusDisabled }) }}" class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || value <= min }) }}"
style="{{ showMinus ? '' : 'display: none;' }}" style="{{ showMinus ? '' : 'display: none;' }}"
hover-class="van-stepper__minus--hover" hover-class="van-stepper__minus--hover"
hover-stay-time="70" hover-stay-time="70"
@ -20,7 +20,7 @@
bind:blur="onBlur" bind:blur="onBlur"
/> />
<view <view
class="plus-class {{ utils.bem('stepper__plus', { disabled: plusDisabled }) }}" class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || value >= max }) }}"
style="{{ showPlus ? '' : 'display: none;' }}" style="{{ showPlus ? '' : 'display: none;' }}"
hover-class="van-stepper__plus--hover" hover-class="van-stepper__plus--hover"
hover-stay-time="70" hover-stay-time="70"