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

onBlur 里做校验时,无法拿到 format 后的 value 值 #548

Open
promise96319 opened this issue Mar 1, 2023 · 1 comment
Open

Comments

@promise96319
Copy link

代码如下:

<InputNumber
  precision={0}
  onBlur={() => console.log('blur')}
  onChange={() => console.log('change')}
/>

当使用 precision 时,如果输入的内容不符合当前精度((比如 0.9),此时失焦,会先触发 onBlur,拿到的 value 值为 0.9。然后 InputNumber 组件再将 value 值格式化,触发 onChange, 此时拿到的 value 值是 1。

在业务中,如果在 onBlur 中去做校验,无法拿到最终格式化后的值。需要通过异步去获取,感觉不是很好,是否能在 onBlur 里将值直接格式化后再出发外层 onBlur 事件?

历史版本有相关 issue 和解决,但是最新版似乎没有。

@bombillazo
Copy link

Hello, we are having a similar problem to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants