Ant Design官网表单有组件参数介绍,搜索normalize
<Form.Item
label="数据源名"
name="code"
labelAlign="right"
rules={[
{ required: true, message: '数据源名不能为空!' },
{ type: 'string', max: 30, message: '数据源名最长30位汉字' },
{ pattern: /^[^\s]*$/, message: '禁止输入空格' },
{pattern:/^[0-9a-zA-Z_]{1,}$/,message:'只能输入字母数字下划线'}
]}
maxLength="30"
normalize={(value, prevValue, prevValues) => {
// 转大写
return value.toUpperCase();
}}
>
<Input placeholder="请输入数据源名" autocomplete="off" />
</Form.Item>