fix(Form): scroll to first matched field (#7102)

This commit is contained in:
neverland 2020-09-05 06:18:09 +08:00 committed by GitHub
parent 938e274251
commit 7c3549ad55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,10 +124,12 @@ export default createComponent({
// @exposed-api
scrollToField(name, options) {
this.fields.forEach((item) => {
this.fields.some((item) => {
if (item.name === name) {
item.$el.scrollIntoView(options);
return true;
}
return false;
});
},
@ -167,6 +169,7 @@ export default createComponent({
});
if (this.scrollToError) {
console.log('scrollToField', errors[0].name);
this.scrollToField(errors[0].name);
}
});