let b = utils.formatUnits('bignumber'.toString(), 9); let str1 = b.toString().replace(/\d+\.(\d*)/, "$1"); let str2 = b.substring(0, b.indexOf(".")); let str3 = toThousands(str2); b = str3 + "." + str1; const toThousands = (num) => { let result = "", counter = 0; num = (num || 0).toString(); for (let i = num.length - 1; i >= 0; i--) { counter++; result = num.charAt(i) + result; if (!(counter % 3) && i != 0) { result = "," + result; } } return result; };
标签:toString,处理,counter,str3,num,let,result,余额,ethers From: https://www.cnblogs.com/eternityyl/p/17394629.html