From a49a38c5f97498a8a56a754752e8085c2ea83e8e Mon Sep 17 00:00:00 2001
From: icssoa <615206459@qq.com>
Date: Sun, 9 Nov 2025 23:28:07 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20precision=20=E7=9A=84=E6=A0=A1?=
=?UTF-8?q?=E9=AA=8C=E7=B1=BB=E5=9E=8B=E7=94=B1=20number=20=E8=B0=83?=
=?UTF-8?q?=E6=95=B4=E4=B8=BA=20digit?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/demo/form/input.uvue | 12 +++++++-----
.../cool-ui/components/cl-input/cl-input.uvue | 5 +++--
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/pages/demo/form/input.uvue b/pages/demo/form/input.uvue
index ac2bb79..5d253d2 100644
--- a/pages/demo/form/input.uvue
+++ b/pages/demo/form/input.uvue
@@ -60,13 +60,15 @@
- 当 type 为 number 时,可设置 precision 属性来保留精度
+ 当 type 为 digit 时,可设置 precision 属性来保留精度
-
-
-
+
-
+
+
+
+
+
diff --git a/uni_modules/cool-ui/components/cl-input/cl-input.uvue b/uni_modules/cool-ui/components/cl-input/cl-input.uvue
index 04fd0eb..7c8cfb0 100644
--- a/uni_modules/cool-ui/components/cl-input/cl-input.uvue
+++ b/uni_modules/cool-ui/components/cl-input/cl-input.uvue
@@ -23,6 +23,7 @@
>
+
= 0 && value.value != "") {
+ if (props.type == "digit" && props.precision >= 0 && value.value != "") {
const parts = value.value.split(".");
return parts.length > 1 && parts[1].length > props.precision;
} else {
@@ -289,7 +290,7 @@ function onBlur(e: UniInputBlurEvent) {
emit("blur", e);
// 处理数字精度
- if (props.type == "number" && props.precision > 0 && value.value != "") {
+ if (props.type == "digit" && props.precision > 0 && value.value != "") {
const numValue = parseFloat(value.value);
if (!isNaN(numValue)) {
const formattedValue = numValue.toFixed(props.precision);