!39 修复了商品卡片没有正确格式化数字的问题

Merge pull request !39 from DH/master
pull/42/MERGE
芋道源码 2024-03-01 05:09:04 +00:00 committed by Gitee
commit eea2ad446f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 4 additions and 2 deletions

View File

@ -55,8 +55,10 @@ export function formatNum(prefix, type, num) {
// 情况三:大于 10除第一位外其它位都显示为0
// 例如100 - 199 显示为 100+
// 9000 - 9999 显示为 9000+
let pow = Math.pow(10, `${num}`.length - 1);
return `${prefix}${(num / pow) * pow}+`;
const numStr = num.toString();
const first = numStr[0];
const other = '0'.repeat(numStr.length - 1);
return `${prefix}${first}${other}+`;
}
// 格式化价格