1.原生方法
new Intl.NumberFormat('zh-CN', { style: 'currency', currency: 'CNY'}).format(123456.789)
2正则匹配
需要先格式化一下数字让其必须有小数点才行:new Number("12345678.123456").toFixed(2).replace(/\d+?(?=(\d{3})+?\.)/g,"$&,")
直接整数的写法:"12345678".replace(/\d+?(?=(\d{3})+?$)/g,"$&,")