From 87a6b962e7c45b0e3210996ca7eb9cd00562e90e Mon Sep 17 00:00:00 2001 From: DH Date: Mon, 29 Jan 2024 01:34:51 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E9=97=AE=E9=A2=98=20=20sheep/hooks/useGoods.?= =?UTF-8?q?js=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=95=B0=E5=AD=97=20=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=89=E6=97=B6=E6=B2=A1=E6=9C=89=E5=AF=B9=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: DH --- sheep/hooks/useGoods.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sheep/hooks/useGoods.js b/sheep/hooks/useGoods.js index 73893bf5..c3c58fe8 100644 --- a/sheep/hooks/useGoods.js +++ b/sheep/hooks/useGoods.js @@ -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}${Math.round((num / pow) * pow)}+`; + const numStr = num.toString(); + const first = numStr[0]; + const other = '0'.repeat(numStr.length - 1); + return `${prefix}${first}${other}+`; } // 格式化价格