antd component pro 表格输入框字符限制

1. 问题现象

1.antd component table筛选条件输入框字符限制

因antd的表格是由ProColumns数组生成的输入框、下拉框、列表等
{
title: ‘用户名称’,
align: 'center',
dataIndex: 'nickName',
},
需对以上对象输入框进行输入字符限制

 

2. 问题原因

ant-design/pro-table版本太低,无法使用formItemProps

3. 解决办法

1.将ant-design/pro-table依赖升级为2.60以上

2.给ProTable标签加上form={{ ignoreRules: false,}}

3.使用formItemProps对象进行限制

 

{
title: '邮箱号码',
dataIndex: 'emailNumber',
formItemProps: {
rules: [
{
required: true,
message: '邮箱号码必填',
},
{
pattern:/[\S]+@[\S]+\.(\S){1,6}/,
message:'请输入正确的邮箱号码'
}
],
},
},
 
posted @ 2022-08-15 11:33  时光SHG  阅读(700)  评论(0)    收藏  举报