fix: input-number 在大数输入下不处理精度 Closes #6334 (#9012)

This commit is contained in:
吴多益 2023-12-25 11:31:01 +08:00 committed by GitHub
parent 71c3324170
commit 082b0d6398
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -187,7 +187,7 @@ export default class NumberControl extends React.Component<
this.handleChangeUnit = this.handleChangeUnit.bind(this);
const unit = this.getUnit();
const unitOptions = normalizeOptions(props.unitOptions);
const {formItem, setPrinstineValue, precision, step, value} = props;
const {formItem, setPrinstineValue, precision, step, value, big} = props;
const normalizedPrecision = NumberInput.normalizePrecision(
this.filterNum(precision),
this.filterNum(step)
@ -201,7 +201,9 @@ export default class NumberControl extends React.Component<
formItem &&
value != null &&
normalizedPrecision != null &&
(!unit || unitOptions.length === 0)
(!unit || unitOptions.length === 0) &&
// 大数下不需要进行精度处理,因为输入输出都是字符串
big !== true
) {
const normalizedValue = parseFloat(
toFixed(value.toString(), '.', normalizedPrecision)