<ProFormText
label='xxx'
name='d'
width="sm"
fieldProps={{
maxLength: 3,
onChange: (e) => formRef.current?.setFieldValue('d', e.target.value.replace(/[^0-9]+/, '')) //只能输入数字
}}
rules={[
{ required: true, message: '请输入' }, //必填项设置
{
validator: (_,value,callback) => { //最大值设置
const max = 180;
if (Number(value) > max) {
callback('最大输入180!')
return;
}
callback();
}
} ]}
/>