fix form async validate bug (#1936)

pull/1898/head
baiyaaaaa 2016-12-23 00:49:45 +08:00 committed by cinwell.li
parent 12e4b02e31
commit f414049311
1 changed files with 2 additions and 1 deletions

View File

@ -54,12 +54,13 @@
},
validate(callback) {
let valid = true;
let count = 0;
this.fields.forEach((field, index) => {
field.validate('', errors => {
if (errors) {
valid = false;
}
if (typeof callback === 'function' && index === this.fields.length - 1) {
if (typeof callback === 'function' && ++count === this.fields.length) {
callback(valid);
}
});