mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
fix(Form): scroll to first matched field (#7102)
This commit is contained in:
parent
938e274251
commit
7c3549ad55
@ -124,10 +124,12 @@ export default createComponent({
|
|||||||
|
|
||||||
// @exposed-api
|
// @exposed-api
|
||||||
scrollToField(name, options) {
|
scrollToField(name, options) {
|
||||||
this.fields.forEach((item) => {
|
this.fields.some((item) => {
|
||||||
if (item.name === name) {
|
if (item.name === name) {
|
||||||
item.$el.scrollIntoView(options);
|
item.$el.scrollIntoView(options);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -167,6 +169,7 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.scrollToError) {
|
if (this.scrollToError) {
|
||||||
|
console.log('scrollToField', errors[0].name);
|
||||||
this.scrollToField(errors[0].name);
|
this.scrollToField(errors[0].name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user