Element: 表单验证的validateField方法怎么用呢?

Created on 12 Feb 2017  ·  5Comments  ·  Source: ElemeFE/element

vue 2.1.6
element-ui 1.1.6

this.$refs[form].validateField('smsPhoneNum', (valid) => {
if(valid){
console.log('OK');
} else {
return false;
}
});

这样没用,请大神指点。

Most helpful comment

this.$refs[form].validateField('smsPhoneNum', (error) => {
if(!error){
console.log('OK');
} else {
return false;
}
});

All 5 comments

this.$refs[form].validateField('smsPhoneNum', (error) => {
if(!error){
console.log('OK');
} else {
return false;
}
});

如果没有errors,就说明验证通过了。。。这个还是有点奇怪,为什么不给每个prop返回一个valid呢

我写成了error 但是回调函数没有执行 这个是为什么呢

没有执行是因为在验证的时候成功了也需要调用callback

传入一个数组,为什么对数组的每一个字段都回调了一次callback

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fscardua picture fscardua  ·  3Comments

Zhao-github picture Zhao-github  ·  3Comments

yuchonghua picture yuchonghua  ·  3Comments

Kingwl picture Kingwl  ·  3Comments

no5no6 picture no5no6  ·  3Comments