Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我使用“解析”,则用户无法输入小数分隔符。
因为“9”。被解析为9并立即替换输入文本。
沙盒:https ://codesandbox.io/s/xmj92nnpo
我最终得到了我自己的 StatefulInput 组件,内部状态为“编辑”标志。我只在模糊时调用 Field 的“onChange”事件处理程序。
https://codesandbox.io/s/2zpn29zzjj
是的。这是一个常见的问题。如果要允许小数点,则必须将值保留为字符串,然后在提交时将其转换为数字。您仍然可以使用parse删除任何非法字符(或type="number"您的<input>),但您不能在每次按键时将其解析为数字,否则您将丢失小数点。
parse
type="number"
<input>