Skip to content

Commit

Permalink
docs(input): use Intl.NumberFormat (#34985)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Apr 13, 2022
1 parent d66784a commit 3142c10
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions components/input/demo/tooltip.md
Expand Up @@ -17,19 +17,7 @@ You can use the Input in conjunction with [Tooltip](/components/tooltip) compone
import { Input, Tooltip } from 'antd';

function formatNumber(value) {
value += '';
const list = value.split('.');
const prefix = list[0].charAt(0) === '-' ? '-' : '';
let num = prefix ? list[0].slice(1) : list[0];
let result = '';
while (num.length > 3) {
result = `,${num.slice(-3)}${result}`;
num = num.slice(0, num.length - 3);
}
if (num) {
result = num + result;
}
return `${prefix}${result}${list[1] ? `.${list[1]}` : ''}`;
return new Intl.NumberFormat().format(value);
}

class NumericInput extends React.Component {
Expand Down

0 comments on commit 3142c10

Please sign in to comment.