方法一(被处理的必须为 Number 类型)
let str = 123456789; y.toLocaleString() //123,456,789
方法二(被处理的为String类型的数字)
let reg = /(\d)(?=(?:\d{4})+$)/g; let str = '123456789'; let target = str.replace(reg, '$1,') //1,2345,6789
方法一(被处理的必须为 Number 类型)
let str = 123456789; y.toLocaleString() //123,456,789
方法二(被处理的为String类型的数字)
let reg = /(\d)(?=(?:\d{4})+$)/g; let str = '123456789'; let target = str.replace(reg, '$1,') //1,2345,6789