数字格式化
作者:互联网
function numberFormat(value) {
let param = {};
let k = 10000;
let sizes = ['', '万', '亿', '万亿'];
let i;
if (value < k) {
param.value = value;
param.unit = '';
} else {
i = Math.floor(Math.log(value) / Math.log(k));
param.value = ((value / Math.pow(k, i))).toFixed(2);
param.unit = sizes[i];
}
return param;
}
标签:格式化,数字,sizes,param,unit,let,value,Math 来源: https://www.cnblogs.com/zhuangbowu/p/16203011.html