标签:ber def hang ret cti with format fun comm
<Input
style={{ width: 80 }}
value={percent.commission}
defaultValue={0}
onChange={(e) => {
let { value } = e.target;
let re = /(^(\d|[1-9]\d)(\.\d{0,2})?$)|(^100$)/;
if(!re.test(value)){
value = value.substring(0,value.length-1)
}
dispatch({
type: "percent/updatePayload",
payload: {
commission: value,
},
});
}}
></Input>
//格式化数字
function formatNum(num) {
if(!num){
return ‘0.00‘
}
if(num.toString().endsWith(".")){
return num + ‘00‘
}
return parseFloat(num).toFixed(2);
}
标签:ber def hang ret cti with format fun comm
原文地址:https://www.cnblogs.com/chengyunshen/p/13087289.html