Merge pull request #3676 from huanghong1125/input-number

fixed input-number null bug
This commit is contained in:
Aresn 2018-05-24 10:22:47 +08:00 committed by GitHub
commit 4b365f6326
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -41,7 +41,7 @@
<template>
<div>
<InputNumber :max="1000000000" :min="1" v-model="value1" :formatter="formatter" :parser="parser" @on-change="change" style="width: 200px"></InputNumber>
<!-- <InputNumber :max="1000000000" :min="1" v-model="value1" :formatter="formatter" :parser="parser" @on-change="change" style="width: 200px"></InputNumber>
<InputNumber :max="1000000000" :min="1" v-model="value2" :formatter="formatter2" :parser="parser2" @on-change="change" style="width: 200px"></InputNumber>
<InputNumber @on-change="change" style="width: 200px"></InputNumber>
@ -51,7 +51,10 @@
<InputNumber v-model="value2" @on-focus="focus" style="width: 200px"></InputNumber>
<InputNumber v-model="value3" style="width: 200px" placeholder="Enter something..."></InputNumber>
<InputNumber v-model="value3" style="width: 200px" placeholder="Enter something..."></InputNumber> -->
<InputNumber v-model="valueNull" style="width: 200px" :min='0' :max='10000' :precision='2' ></InputNumber>
</div>
</template>
<script>

View file

@ -181,6 +181,7 @@
},
precisionValue () {
// can not display 1.0
if(!this.currentValue) return this.currentValue;
return this.precision ? this.currentValue.toFixed(this.precision) : this.currentValue;
},
formatterValue () {
@ -247,7 +248,7 @@
},
setValue (val) {
// step precision
if (!isNaN(this.precision)) val = Number(Number(val).toFixed(this.precision));
if (val && !isNaN(this.precision)) val = Number(Number(val).toFixed(this.precision));
this.$nextTick(() => {
this.currentValue = val;