support InputNumber

support InputNumber
This commit is contained in:
梁灏 2017-03-02 13:40:09 +08:00
parent 456daf3492
commit c97c42ab2e
8 changed files with 50 additions and 14 deletions

View file

@ -92,7 +92,8 @@
return {
focused: false,
upDisabled: false,
downDisabled: false
downDisabled: false,
currentValue: this.value
};
},
computed: {
@ -164,7 +165,7 @@
}
const targetVal = Number(e.target.value);
let val = Number(this.value);
let val = Number(this.currentValue);
const step = Number(this.step);
if (isNaN(val)) {
return false;
@ -196,9 +197,11 @@
},
setValue (val) {
this.$nextTick(() => {
this.value = val;
this.currentValue = val;
this.$emit('input', val);
this.$emit('on-change', val);
this.$dispatch('on-form-change', val);
// todo
// this.$dispatch('on-form-change', val);
});
},
focus () {
@ -224,7 +227,7 @@
if (isValueNumber(val)) {
val = Number(val);
this.value = val;
this.currentValue = val;
if (val > max) {
this.setValue(max);
@ -234,7 +237,7 @@
this.setValue(val);
}
} else {
event.target.value = this.value;
event.target.value = this.currentValue;
}
},
changeVal (val) {
@ -250,11 +253,14 @@
}
}
},
compiled () {
this.changeVal(this.value);
mounted () {
this.changeVal(this.currentValue);
},
watch: {
value (val) {
this.currentValue = val;
},
currentValue (val) {
this.changeVal(val);
}
}