JS把数字转换为千分位字符串

64 阅读1分钟

方法1

Number(num).toLocaleString()

方法2

String(num).replace(/\B(?=(\d{3})+(?!\d))/g, ',')