ant-design/components/input-number/demo/digit.md

38 lines
781 B
Markdown
Raw Normal View History

2016-04-15 23:56:44 +08:00
---
order: 3
2016-08-18 15:59:07 +08:00
title:
zh-CN: 高精度小数
en-US: High precision decimals
2016-04-15 23:56:44 +08:00
---
2016-04-15 23:39:39 +08:00
2016-08-18 15:59:07 +08:00
## zh-CN
2021-03-31 16:07:24 +08:00
通过 `stringMode` 开启高精度小数支持,`onChange` 事件将返回 string 类型。对于旧版浏览器,你需要 BigInt polyfill。
2016-08-18 15:59:07 +08:00
## en-US
Use `stringMode` to support high precision decimals support. `onChange` will return string value instead. You need polyfill of BigInt if browser not support.
2016-04-15 23:39:39 +08:00
```tsx
2016-04-15 23:39:39 +08:00
import { InputNumber } from 'antd';
2022-05-23 14:37:16 +08:00
import React from 'react';
2016-04-15 23:39:39 +08:00
const onChange = (value: string) => {
2016-04-15 23:39:39 +08:00
console.log('changed', value);
};
2016-04-15 23:39:39 +08:00
const App: React.FC = () => (
<InputNumber<string>
style={{ width: 200 }}
defaultValue="1"
min="0"
max="10"
step="0.00000000000001"
onChange={onChange}
stringMode
/>
);
export default App;
2019-05-07 14:57:32 +08:00
```