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