将 precision 的校验类型由 number 调整为 digit
This commit is contained in:
@@ -60,13 +60,15 @@
|
|||||||
</demo-item>
|
</demo-item>
|
||||||
|
|
||||||
<demo-item :label="t('保留精度')">
|
<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 type="digit" :precision="precision"></cl-input>
|
||||||
<cl-input-number v-model="precision"></cl-input-number>
|
|
||||||
</cl-list-item>
|
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
<demo-item :label="t('自定义')">
|
<demo-item :label="t('自定义')">
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
></cl-icon>
|
></cl-icon>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- @vue-ignore -->
|
||||||
<input
|
<input
|
||||||
class="cl-input__inner"
|
class="cl-input__inner"
|
||||||
:class="[
|
:class="[
|
||||||
@@ -265,7 +266,7 @@ const isPassword = ref(props.password);
|
|||||||
// 是否超出限制
|
// 是否超出限制
|
||||||
const isExceed = computed(() => {
|
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(".");
|
const parts = value.value.split(".");
|
||||||
return parts.length > 1 && parts[1].length > props.precision;
|
return parts.length > 1 && parts[1].length > props.precision;
|
||||||
} else {
|
} else {
|
||||||
@@ -289,7 +290,7 @@ function onBlur(e: UniInputBlurEvent) {
|
|||||||
emit("blur", e);
|
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);
|
const numValue = parseFloat(value.value);
|
||||||
if (!isNaN(numValue)) {
|
if (!isNaN(numValue)) {
|
||||||
const formattedValue = numValue.toFixed(props.precision);
|
const formattedValue = numValue.toFixed(props.precision);
|
||||||
|
|||||||
Reference in New Issue
Block a user