This commit is contained in:
rhyme 2020-06-17 12:11:58 +08:00
parent c87f7f730b
commit c09e262f39

View file

@ -16,7 +16,7 @@
<input
:id="elementId"
:class="inputClasses"
:disabled="itemDisabled"
:disabled="disabled"
autocomplete="off"
spellcheck="false"
:autofocus="autofocus"
@ -36,7 +36,6 @@
<script>
import { oneOf, findComponentUpward } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
import mixinsForm from '../../mixins/form';
const prefixCls = 'ivu-input-number';
const iconPrefixCls = 'ivu-icon';
@ -67,7 +66,7 @@
export default {
name: 'InputNumber',
mixins: [ Emitter, mixinsForm ],
mixins: [ Emitter ],
props: {
max: {
type: Number,
@ -87,7 +86,7 @@
},
value: {
type: Number,
default: 1
default: null,
},
size: {
validator (value) {
@ -147,7 +146,7 @@
`${prefixCls}`,
{
[`${prefixCls}-${this.size}`]: !!this.size,
[`${prefixCls}-disabled`]: this.itemDisabled,
[`${prefixCls}-disabled`]: this.disabled,
[`${prefixCls}-focused`]: this.focused
}
];
@ -187,8 +186,13 @@
},
precisionValue () {
// can not display 1.0
if(!this.currentValue) return this.currentValue;
return this.precision ? this.currentValue.toFixed(this.precision) : this.currentValue;
// if(!this.currentValue) return this.currentValue;
// return this.precision ? this.currentValue.toFixed(this.precision) : this.currentValue;
let arr = (this.currentValue + '').split('.');
if (this.precision && arr[1] && this.precision < arr[1].length) {
return this.currentValue.toFixed(this.precision);
}
return this.currentValue;
},
formatterValue () {
if (this.formatter && this.precisionValue !== null) {
@ -217,7 +221,7 @@
this.changeStep('down', e);
},
changeStep (type, e) {
if (this.itemDisabled || this.readonly) {
if (this.disabled || this.readonly) {
return false;
}
@ -293,7 +297,6 @@
}
},
change (event) {
if (event.type == 'change' && this.activeChange) return;
if (event.type == 'input' && !this.activeChange) return;
let val = event.target.value.trim();