数字实现千分位分隔符
方法一(被处理的必须为 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
本文来自博客园,作者:_zhiqiu,转载请注明原文链接:https://www.cnblogs.com/guojikun/p/11195922.html