// normal 参数是币种 币种等于 JPY 【日元】不显示千元符 默认显示千元符 function toThousands(num = 0, currency = 'normal', point = 2) { let newNum = String(num) var reg = new RegExp(',', 'g') if (newNum.indexOf(',') !== -1) { newNum = newNum.replace(reg, '') } let zero = '.00' if (newNum === 'null') { newNum = 0 } else { newNum = Number(newNum) } if (currency === 'JPY') zero = '' var [sInt, sFloat] = (Number.isInteger(newNum) ? `${newNum}` : newNum.toFixed(point)).split('.') sInt = sInt.replace(/\d(?=(\d{3})+$)/g, '$&,') return sFloat ? `${sInt}.${sFloat}` : `${sInt}` + `${zero}` }