thousandsSeparator(num, point) {
let _point = (point === 0) ? 0 : (point || 2),
_num = String(num).indexOf('.')>-1 ? num.toFixed(_point) : num,
str = _num.toString(),
reg = str.indexOf(".") > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
return str.replace(reg, "$1,");
}
网友评论