Commit cb2678c4b93bead14dd2cdd96ff7a39034429c98
1 parent
7fdad3a3
fix InputNumber bug in 2.4.0, and release 2.4.0-beta.3
Showing
3 changed files
with
8 additions
and
5 deletions
Show diff stats
examples/routers/input-number.vue
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | <!--<div @click="changeMax">change max</div>--> |
7 | 7 | <!--<Input-number disabled :max="10" :min="1" :step="1.2" v-model="v2"></Input-number>--> |
8 | 8 | <!--<Input-number :max="10" :min="1" v-model="obj.v"></Input-number>--> |
9 | - {{ value1 }} | |
9 | + <InputNumber :max="10" :min="1" :step="1.2" v-model="value2"></InputNumber> | |
10 | 10 | <InputNumber :precision="1" :max="10" :min="1" :step="0.1" v-model="value1"></InputNumber> |
11 | 11 | </div> |
12 | 12 | </template> |
... | ... | @@ -22,7 +22,8 @@ |
22 | 22 | obj: { |
23 | 23 | |
24 | 24 | }, |
25 | - value1: 1.0 | |
25 | + value1: 1.0, | |
26 | + value2: 1 | |
26 | 27 | }; |
27 | 28 | }, |
28 | 29 | computed: {}, | ... | ... |
package.json
src/components/input-number/input-number.vue
... | ... | @@ -161,7 +161,7 @@ |
161 | 161 | }, |
162 | 162 | precisionValue () { |
163 | 163 | // can not display 1.0 |
164 | - return this.currentValue.toFixed(this.precision); | |
164 | + return this.precision ? this.currentValue.toFixed(this.precision) : this.currentValue; | |
165 | 165 | } |
166 | 166 | }, |
167 | 167 | methods: { |
... | ... | @@ -219,7 +219,9 @@ |
219 | 219 | this.setValue(val); |
220 | 220 | }, |
221 | 221 | setValue (val) { |
222 | - val = Number(Number(val).toFixed(this.precision)); | |
222 | + // 如果 step 是小数,且没有设置 precision,是有问题的 | |
223 | + if (this.precision) val = Number(Number(val).toFixed(this.precision)); | |
224 | + | |
223 | 225 | this.$nextTick(() => { |
224 | 226 | this.currentValue = val; |
225 | 227 | this.$emit('input', val); | ... | ... |