//数值先保留2位小数,再千分位处理
export function numFormat2(num: any = 0, decimal = 2) {
num = Number(num) || 0;
num = Math.round(num * 10000) / 10000;
num = num.toFixed(decimal);
let [num1, num2] = num.split('.');
num1 = num1.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
let str=num1++ num2;
}
return str;
JavaScript数值先保留2位小数,再做千分位处理
于 2024-05-30 09:43:41 首次发布