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
When InputNumber has a formatter attribute, it is not possible to enter a decimal with a negative zero point, such as -0.121 #6360
Comments
remove min prop |
和min prop无关。 暂时找到一个临时解决方法。 就是在自己的formatter方法里面拿input值,发现是-0,直接返回出来。 // return value; |
这就是个示例代码问题吧,组件不用动 |
可以看看ant design那边的例子,同样的输入行为是不一样的 |
@zkwolf 也有问题 https://codesandbox.io/s/ge-shi-hua-zhan-shi-antd-5-3-2-forked-481kor?file=/demo.tsx |
@tangjinzhou 这里好像是因为 输入-0 的时候 decimalValue.toNumber() 将 -0 变成了 0 然后双向绑定,最后的显示的值变成了0,我想这样去解决这个问题你怎么看? const getDecimalValue = (stringMode: boolean, decimalValue: DecimalClass) => {
if (stringMode || decimalValue.isEmpty()) {
return decimalValue.toString();
}
const strVal = decimalValue.toString(false);
if (/^-0$/.test(strVal)) {
return strVal;
}
return decimalValue.toNumber();
}; |
@wolfidea 您目前可以考虑使用 stringMode prop 处理你的问题 |
Version
3.3.0-beta.4
Environment
vue3 ant-design-vue 3.2.15
Reproduction link
Steps to reproduce
InputNumber 存在formatter属性时候,输入 -0.1 ,会被格式化成0.1
What is expected?
期望存在formatter时,可以输入 -0.121
What is actually happening?
一直存在
The text was updated successfully, but these errors were encountered: