mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Form): scrollToField can scroll to bottom (#6335)
This commit is contained in:
parent
6630816742
commit
96ef2557c2
@ -457,12 +457,12 @@ export default {
|
|||||||
|
|
||||||
Use [ref](https://vuejs.org/v2/api/#ref) to get Form instance and call instance methods
|
Use [ref](https://vuejs.org/v2/api/#ref) to get Form instance and call instance methods
|
||||||
|
|
||||||
| Name | Description | Attribute | Return value |
|
| Name | Description | Attribute | Return value |
|
||||||
| ---------------------- | ---------------- | --------------- | ------------ |
|
| --- | --- | --- | --- |
|
||||||
| submit | Submit form | - | - |
|
| submit | Submit form | - | - |
|
||||||
| validate | Validate form | _name?: string_ | _Promise_ |
|
| validate | Validate form | _name?: string_ | _Promise_ |
|
||||||
| resetValidation | Reset validation | _name?: string_ | - |
|
| resetValidation | Reset validation | _name?: string_ | - |
|
||||||
| scrollToField `v2.5.2` | Scroll to field | _name: string_ | - |
|
| scrollToField `v2.8.2` | Scroll to field | _name: string, alignToTop: boolean_ | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ export default {
|
|||||||
| submit | 提交表单,与点击提交按钮的效果等价 | - | - |
|
| submit | 提交表单,与点击提交按钮的效果等价 | - | - |
|
||||||
| validate | 验证表单,支持传入`name`来验证单个表单项 | _name?: string_ | _Promise_ |
|
| validate | 验证表单,支持传入`name`来验证单个表单项 | _name?: string_ | _Promise_ |
|
||||||
| resetValidation | 重置表单项的验证提示,支持传入`name`来重置单个表单项 | _name?: string_ | - |
|
| resetValidation | 重置表单项的验证提示,支持传入`name`来重置单个表单项 | _name?: string_ | - |
|
||||||
| scrollToField `v2.5.2` | 滚动到对应表单项的位置 | _name: string_ | - |
|
| scrollToField `v2.8.2` | 滚动到对应表单项的位置,默认滚动到顶部,第二个参数传 false 可滚动至底部 | _name: string, alignToTop: boolean_ | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -119,10 +119,10 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// @exposed-api
|
// @exposed-api
|
||||||
scrollToField(name) {
|
scrollToField(name, options) {
|
||||||
this.fields.forEach((item) => {
|
this.fields.forEach((item) => {
|
||||||
if (item.name === name) {
|
if (item.name === name) {
|
||||||
item.$el.scrollIntoView();
|
item.$el.scrollIntoView(options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
2
types/form.d.ts
vendored
2
types/form.d.ts
vendored
@ -7,5 +7,5 @@ export class Form extends VanComponent {
|
|||||||
|
|
||||||
resetValidation(name?: string): void;
|
resetValidation(name?: string): void;
|
||||||
|
|
||||||
scrollToField(name: string): void;
|
scrollToField(name: string, options?: boolean | ScrollIntoViewOptions): void;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user