vue 2.1.6
element-ui 1.1.6
this.$refs[form].validateField('smsPhoneNum', (valid) => {
if(valid){
console.log('OK');
} else {
return false;
}
});
这样没用,请大神指点。
this.$refs[form].validateField('smsPhoneNum', (error) => {
if(!error){
console.log('OK');
} else {
return false;
}
});
如果没有errors,就说明验证通过了。。。这个还是有点奇怪,为什么不给每个prop返回一个valid呢
我写成了error 但是回调函数没有执行 这个是为什么呢
没有执行是因为在验证的时候成功了也需要调用callback
传入一个数组,为什么对数组的每一个字段都回调了一次callback
Most helpful comment
this.$refs[form].validateField('smsPhoneNum', (error) => {
if(!error){
console.log('OK');
} else {
return false;
}
});