fixed #28
This commit is contained in:
梁灏 2016-10-13 23:11:23 +08:00
parent 4935594e4e
commit 0b94936a0e

View file

@ -175,7 +175,10 @@
this.setValue(val); this.setValue(val);
}, },
setValue (val) { setValue (val) {
this.$nextTick(() => {
this.value = val; 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;
} }
}
}, },
watch: { changeVal (val) {
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>