vue过滤器,金额每三位加逗号,
/*** 10000 => "10,000"* @param {number} num*/export function toThousandFilter(num) {return (+num || 0).toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')// return (+num ||...
·
/**
* 10000 => "10,000"
* @param {number} num
*/
export function toThousandFilter(num) {
return (+num || 0).toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
// return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
}
更多推荐
已为社区贡献10条内容
所有评论(0)