Explorar el Código

Input-Number: Fix precision problem (#15292) (#15295)

susiwen8 hace 6 años
padre
commit
af0dc358bc
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      packages/input-number/src/input-number.vue

+ 1 - 1
packages/input-number/src/input-number.vue

@@ -195,7 +195,7 @@
     methods: {
       toPrecision(num, precision) {
         if (precision === undefined) precision = this.numPrecision;
-        return parseFloat(Number(num).toFixed(precision));
+        return parseFloat(Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision));
       },
       getPrecision(value) {
         if (value === undefined) return 0;