parent
4935594e4e
commit
0b94936a0e
1 changed files with 19 additions and 13 deletions
|
@ -175,7 +175,10 @@
|
||||||
this.setValue(val);
|
this.setValue(val);
|
||||||
},
|
},
|
||||||
setValue (val) {
|
setValue (val) {
|
||||||
this.value = val;
|
this.$nextTick(() => {
|
||||||
|
this.value = val;
|
||||||
|
});
|
||||||
|
|
||||||
this.$emit('on-change', val);
|
this.$emit('on-change', val);
|
||||||
},
|
},
|
||||||
focus () {
|
focus () {
|
||||||
|
@ -201,6 +204,8 @@
|
||||||
|
|
||||||
if (isValueNumber(val)) {
|
if (isValueNumber(val)) {
|
||||||
val = Number(val);
|
val = Number(val);
|
||||||
|
this.value = val;
|
||||||
|
|
||||||
if (val > max) {
|
if (val > max) {
|
||||||
this.setValue(max);
|
this.setValue(max);
|
||||||
} else if (val < min) {
|
} else if (val < min) {
|
||||||
|
@ -211,26 +216,27 @@
|
||||||
} else {
|
} else {
|
||||||
event.target.value = this.value;
|
event.target.value = this.value;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
changeVal (val) {
|
||||||
watch: {
|
|
||||||
value (val) {
|
|
||||||
if (isValueNumber(val) || val === 0) {
|
if (isValueNumber(val) || val === 0) {
|
||||||
val = Number(val);
|
val = Number(val);
|
||||||
const step = this.step;
|
const step = this.step;
|
||||||
if (val + step > this.max) {
|
|
||||||
this.upDisabled = true;
|
this.upDisabled = val + step > this.max;
|
||||||
} else if (val - step < this.min) {
|
this.downDisabled = val - step < this.min;
|
||||||
this.downDisabled = true;
|
|
||||||
} else {
|
|
||||||
this.upDisabled = false;
|
|
||||||
this.downDisabled = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.upDisabled = true;
|
this.upDisabled = true;
|
||||||
this.downDisabled = true;
|
this.downDisabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
ready () {
|
||||||
|
this.changeVal(this.value);
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
value (val) {
|
||||||
|
this.changeVal(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
Loading…
Add table
Reference in a new issue