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

Merge pull request !39 from DH/master
This commit is contained in:
芋道源码
2024-03-01 05:09:04 +00:00
committed by Gitee
+4 -2
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}+`;
}
// 格式化价格