antd InputNumber组件保留一位小数
程序员文章站
2022-06-14 19:38:17
...
<a-input-number
:min="0"
:step="0.1"
:formatter="(value)=>{
let reg = /^(-)*(\d+)\.(\d).*$/;
return `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',').replace(reg,'$1$2.$3');
}"
:parser="(value)=>{
let reg = /^(-)*(\d+)\.(\d).*$/;
return value.replace(/\s?|(,*)/g, '').replace(reg,'$1$2.$3');
}"
/>