js有效数字三位不科学计数法
可以使用 toLocaleString() 方法,设置参数为 {maximumFractionDigits: 3},将数字格式化为三位有效数字的字符串形式。
例如:
let num = 1234567.89; let str = num.toLocaleString(undefined, {maximumFractionDigits: 3});
console.log(str); // "1,230,000"
原文地址: http://www.cveoy.top/t/topic/htLa 著作权归作者所有。请勿转载和采集!