Procházet zdrojové kódy

feat(util): 小数位数处理

zhangweicheng před 2 roky
rodič
revize
9cddf342cb
2 změnil soubory, kde provedl 3 přidání a 3 odebrání
  1. 2 2
      util/package.json
  2. 1 1
      util/src/math.ts

+ 2 - 2
util/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/util",
-  "version": "1.0.11",
+  "version": "1.0.12",
   "description": "通用的工具包",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",
@@ -50,4 +50,4 @@
   "dependencies": {
     "lodash": "^4.17.21"
   }
-}
+}

+ 1 - 1
util/src/math.ts

@@ -24,7 +24,7 @@ export const innerRound = (num: number, length: number, decimal: number): number
 export const roundForObj = (obj: string | number | undefined | null, decimal: number): number => {
   let value;
   if (obj === undefined || obj === null || isNaN(obj as number)) return 0;
-  const length = 10;
+  const length = decimal + 2;
   if (obj === +obj) {
     value = innerRound(obj, length, decimal);
   } else {