数字添加千位符
// 千位符
export function toThousands(num) {
if (!num) {
return '0.00'
}
if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(num)) {
return num
}
var a = RegExp.$1; var b = RegExp.$2; var c = RegExp.$3
var re = new RegExp().compile('(\\d)(\\d{3})(,|$)')
while (re.test(b)) {
b = b.replace(re, '$1,$2$3')
}
return a + '' + b + '' + c
}