Skip to content

Commit ff8d7ad

Browse files
ruochuan12PanJiaChen
authored andcommitted
千分符考虑小数点
1 parent bf480ca commit ff8d7ad

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/filters/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,8 @@ export function html2Text(val) {
104104

105105

106106
export function toThousandslsFilter(num) {
107-
return (+num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
107+
return (+num || 0).toString()
108+
.replace(/^\-?\d+/g, function(m){
109+
return m.replace(/(?=(?!\b)(\d{3})+$)/g, ',');
110+
});
108111
}

0 commit comments

Comments
 (0)