Antd <a-form>表单校验:v-model、v-decorator

1、表单验证 v-model:

<a-form-model ref="form" :model="form" :rules="rules" >
	<a-form-model-item
        label="身份证号" name="idCard" prop="idCard"
        :labelCol="{span: 5}"
        :wrapperCol="{span: 19}"
      >
        <a-input v-model="form.idCard"/>
    </a-form-model-item>
</a-form-model>
data(){
	return{
		//验证规则
		rules:{
			password: [
				{
		            required: true, pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{8,}$/, message: '密码由8位数字、大小写字母和特殊符号组成!!'
		        }
		    ],
			idCard:[
				{ required: true, message: '密码不能为空!'},
			    { validator: this.validateidCard, trigger: 'change' }
			],
		}
	}
}


//验证身份证号
validateidCard(rule, value, callback) {
  console.log(value)
},

//表单提交
that.$refs['form'].validate(success => {
	if (success === true) {
	
	}
}) 

2、表单验证 v-decorator:

<a-form :form="form">
	<a-form-item
        label="身份证号"
        :labelCol="{span: 5}"
        :wrapperCol="{span: 19}"
      >
        <a-input
          v-decorator.trim="['idCard',validatorRules.idCard]"
          placeholder="请输入身份证号"
        />
    </a-form-item>
</a-form>
data(){
	return{
		form:this.$form.createForm(this),
		//验证规则
		validatorRules: {
			name:{
				rules: [
					{ required: true, message: '请输入代理人用户名!' }
				]
			},
			idCard: {
		      rules: [
		        { required: true, message: '' },
		        { validator: this.validateidCard }
		      ]
		    },
		}
	}
}

//验证身份证号
validateidCard(rule, value, callback) {
    console.log(value)
}

//修改值
this.form.setFieldsValue({
  name: '设置值'
})
//取值
this.form.getFieldValue('name')

//表单提交
this.form.validateFields((err, values) => {
	if (!err) {

	}
})