view-design / ViewUIPlus

An enterprise-level UI component library and front-end solution based on Vue.js 3
https://www.iviewui.com
Other
384 stars 133 forks source link

[Bug Report]nputNumber限制了输入位数,在失去焦点的时候会多加一位 #373

Open loveCoderJ opened 5 months ago

loveCoderJ commented 5 months ago

Environment

"vue": "^3.4.27",chrome

Reproduction link

https://run.iviewui.com/

Steps to reproduce

当我使用指令或者事件去限制了input能输入的位数,在我失去焦点的时候会自动多加一位,必须在绑定一个失焦事件再去限制一下才能解决这个问题

What is expected?

在去焦点的时候不会再多赋值一位,无需额外事件去处理

What is actually happening?

需要额外的事件去处理,再去截取一下需求的位数

dosubot[bot] commented 5 months ago

@loveCoderJ 你好! 我是一个能够帮助你解决问题,回答你的疑问,以及成为贡献者的机器人。在等待人类维护者的过程中,我将会一直在这里帮助你。

The InputNumber component in ViewUIPlus has a precision property that controls the number of decimal places for the value. If the component adds an extra digit when losing focus, it is likely due to the precision property not being set correctly.

To resolve this issue without needing an additional blur event, you should set the precision property to the desired number of decimal places. This ensures that the value is formatted correctly when the input loses focus.

Here is an example of how to use the precision property:

<template>
  <InputNumber v-model="value" :precision="2" />
</template>

<script>
export default {
  data() {
    return {
      value: 0
    };
  }
};
</script>

In this example, the precision is set to 2, which means the value will be formatted to two decimal places when the input loses focus. Additionally, the formatterValue property in the component ensures that the value is displayed correctly in the input field [1][2].

To continue talking to Dosu, mention @dosu.