该错误提示是由于在使用InputNumber控件时传入的precision参数超出了数值的范围所引起的。解决方法是在使用时对precision参数进行检查或者使用try-catch语句提供错误处理。
以下是对precision参数进行检查的代码示例:
import React, { useState } from "react";
import { InputNumber } from "antd";
const MyComponent = () => {
const [value, setValue] = useState(0);
const [precision, setPrecision] = useState(0);
const handleChange = (value) => {
setValue(value);
};
const handlePrecisionChange = (value) => {
if (value >= 0 && value <= 100) {
setPrecision(value);
}
};
return (
<>
>
);
};
export default MyComponent;
以上代码中,我们针对precision参数的取值范围进行了检查。如果precision的值超出了0~100的范围,就不会更新precision的值,从而避免了出现错误提示。