千分符考虑小数点

This commit is contained in:
轩辕Rowboat 2017-06-20 14:10:51 +08:00 committed by Pan
parent bf480ca6b4
commit ff8d7ada73

View file

@ -104,5 +104,8 @@ export function html2Text(val) {
export function toThousandslsFilter(num) {
return (+num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
return (+num || 0).toString()
.replace(/^\-?\d+/g, function(m){
return m.replace(/(?=(?!\b)(\d{3})+$)/g, ',');
});
}