主要是借用math.js库来完成:
1 import { create, all } from ‘math.min.js‘ 2 3 const config = { 4 number: ‘BigNumber‘, 5 precision: 20, 6 } 7 8 9 //乘 10 function numberRide(arg1, arg2) { 11 return Number(math.format(math.multiply(math.bignumber(arg1), math.bignumber(arg2)))) 12 } 13 14 //除 15 function numberDivide(arg1,arg2) { 16 return Number(math.format(math.divide(math.bignumber(arg1), math.bignumber(arg2)))) 17 } 18 19 //加 20 function numberAdd(arg1,arg2) { 21 return Number(math.format(math.add(math.bignumber(arg1), math.bignumber(arg2)))) 22 } 23 24 //减 25 numberSubtract(arg1, arg2) { 26 return Number(math.format(math.subtract(math.bignumber(arg1), math.bignumber(arg2)))) 27 }