Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
loveCoderJ opened this issue Jun 27, 2024 · 1 comment
Labels
Bug Something isn't working

Comments

@loveCoderJ
Copy link

Environment

"vue": "^3.4.27",chrome

Reproduction link

https://run.iviewui.com/

Steps to reproduce

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

What is expected?

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

What is actually happening?

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

@dosubot dosubot bot added the Bug Something isn't working label Jun 27, 2024
Copy link

dosubot bot commented Jun 27, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant