mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 01:19:45 +08:00
28 lines
642 B
TypeScript
28 lines
642 B
TypeScript
import React from 'react';
|
|
import { InputNumber, Space } from 'antd';
|
|
|
|
const onChange = (value: number | string) => {
|
|
console.log('changed', value);
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Space>
|
|
<InputNumber
|
|
defaultValue={1000}
|
|
formatter={(value) => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
|
|
parser={(value) => value!.replace(/\$\s?|(,*)/g, '')}
|
|
onChange={onChange}
|
|
/>
|
|
<InputNumber
|
|
defaultValue={100}
|
|
min={0}
|
|
max={100}
|
|
formatter={(value) => `${value}%`}
|
|
parser={(value) => value!.replace('%', '')}
|
|
onChange={onChange}
|
|
/>
|
|
</Space>
|
|
);
|
|
|
|
export default App;
|