form-create icon indicating copy to clipboard operation
form-create copied to clipboard

antd-vue 正则,自定义验证规则均失效

Open YLeeXIE opened this issue 3 years ago • 2 comments

2.5.27

ant-design-vue

1.7.8

问题描述: 组件rule项定义validate 只有required生效,pattern和自定义validator均无效,type为基础input

复现步骤: { type: 'input', field: 'phone', title: '手机', props: { placeholder: '请输入手机', }, validate: [{ required: true,pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误' }], }, 期望: 输入abc 验证手机号格式错误

YLeeXIE avatar Oct 26 '22 08:10 YLeeXIE

试试

 [{ required: true, pattern: '^1[3456789]\d{9}$', message: '手机号码格式错误' }],

xaboy avatar Oct 27 '22 06:10 xaboy

已解决,原因是二次封装数据深拷贝方法不对,没有正确拷贝正则

YLeeXIE avatar Nov 03 '22 06:11 YLeeXIE