mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(Stepper): remove computed (#2000)
This commit is contained in:
parent
a80accbcc2
commit
78681032b8
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user