antdv中使用v-decorator后输入自动转大写
使用了v-decorator后使用v-model会有冲突;所以不能使用v-model,只能考虑使用v-decorator中的方法,记录一下。
// template部分
<a-input
:maxLength="4"
v-decorator="[ 'certType', validatorRules.certType]"
:disabled="disableSubmit"
/>
// An highlighted block
validatorRules: {
certType: {
rules: [{
required: true,
message: 'aaaaaaaa'
}, {
min: 2,
max: 6,
message: '输入2-3个字符!'
}, {
//添加自定义的校验规则
validator: this.handlePass
}],
normalize: certType => {
if (certType != undefined) {
return certType.toUpperCase();
}
}
},
}
normalize要写在与rules同级(开始放在rules内未生效,查了后才知道正确用法)