From 8b41aca29925022df49667f731f1fc19f8f489bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Fri, 18 Jul 2025 18:58:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E5=AD=97=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/common/common.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/js/common/common.js b/common/js/common/common.js index 48d1431d..2663dd88 100644 --- a/common/js/common/common.js +++ b/common/js/common/common.js @@ -918,9 +918,10 @@ export const color_change = (length) => { * @returns 格式化后的数字字符串 */ export const formatNumber = (num, is_convert) => { + let new_num = num.replace(/[^0-9.,]/g, ''); if (is_convert) { // 将输入转换为字符串形式以便处理 - const number = num.toString(); + const number = new_num.toString(); // 使用正则表达式将整数部分每三位用逗号分隔 const integerPart = number.split('.')[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); // 避免小数为空的时候也处理 @@ -929,7 +930,7 @@ export const formatNumber = (num, is_convert) => { return integerPart + decimalPart; } else { // 如果不需要转换,移除所有逗号并返回 - return num.toString().replace(/,/g, ''); + return new_num.toString().replace(/,/g, ''); } };