chanshiyucx
2/18/2019 - 3:18 AM

数字分位格式化

数字分位格式化

export const toThousandFilter = num => {
  return (+num || 0)
    .toString()
    .replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
}