Pārlūkot izejas kodu

将 precision 的校验类型由 number 调整为 digit

icssoa 5 mēneši atpakaļ
vecāks
revīzija
a49a38c5f9

+ 7 - 5
pages/demo/form/input.uvue

@@ -60,13 +60,15 @@
 			</demo-item>
 
 			<demo-item :label="t('保留精度')">
-				<demo-tips>当 type 为 number 时,可设置 precision 属性来保留精度</demo-tips>
+				<demo-tips>当 type 为 digit 时,可设置 precision 属性来保留精度</demo-tips>
 
-				<cl-list-item :label="t('精度')">
-					<cl-input-number v-model="precision"></cl-input-number>
-				</cl-list-item>
+				<cl-input type="digit" :precision="precision"></cl-input>
 
-				<cl-input type="number" :precision="precision"></cl-input>
+				<cl-list border :pt="{ className: 'mt-5' }">
+					<cl-list-item :label="t('精度')">
+						<cl-input-number v-model="precision"></cl-input-number>
+					</cl-list-item>
+				</cl-list>
 			</demo-item>
 
 			<demo-item :label="t('自定义')">

+ 3 - 2
uni_modules/cool-ui/components/cl-input/cl-input.uvue

@@ -23,6 +23,7 @@
 			></cl-icon>
 		</view>
 
+		<!-- @vue-ignore -->
 		<input
 			class="cl-input__inner"
 			:class="[
@@ -265,7 +266,7 @@ const isPassword = ref(props.password);
 // 是否超出限制
 const isExceed = computed(() => {
 	// 检查数字精度是否超出限制
-	if (props.type == "number" && props.precision >= 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);