We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在涉及到金额的时候经常会将金额格式化,小数之前部分,会变成每三个数字一组
toLocaleString
(12546.32).toLocaleString('en-US') //"12,546.32"
function format (num) { var str = num && num.toString() var result = str.split('.') var ret = result[1] ? '.' + result[1] : '' return result[0] .replace(/\d{1,3}(?=(\d{3})+$)/g, function ($2) { return $2 + ',' }) + ret } format(12446.325) // "12,446.325"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在涉及到金额的时候经常会将金额格式化,小数之前部分,会变成每三个数字一组
方法一:
toLocaleString
方法二:使用正则
The text was updated successfully, but these errors were encountered: