fix: 🧩 代码迁移出错

This commit is contained in:
2025-07-15 10:04:39 +08:00
parent eb32b4309e
commit 12fd39b5af
14 changed files with 489 additions and 22 deletions

View File

@@ -0,0 +1,22 @@
//只允许输入数字和小数点(小数点后面5位)
export const numberDecimalSeparatorRexg5 = (value: any) => {
if (!value) {
return;
}
// 清除"数字"和"."以外的字符,只能输入数字和小数点
value = value.replace(/[^\d.]/g, "");
// 不能连续输入两个及以上小数点
value = value.replace(/\.{2,}/g, ".");
// 只保留第一个".", 清除多余的"."
value = value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
// 限制小数点后最多 5 位
const parts = value.split(".");
if (parts.length > 1 && parts[1].length > 5) {
parts[1] = parts[1].slice(0, 5);
value = parts.join(".");
}
return value;
};