mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Form): add submit-on-enter prop (#6336)
This commit is contained in:
parent
96ef2557c2
commit
877ebd6054
@ -356,8 +356,8 @@ export default createComponent({
|
||||
const ENTER_CODE = 13;
|
||||
|
||||
if (event.keyCode === ENTER_CODE) {
|
||||
// should not submit form on etner
|
||||
if (this.type !== 'textarea') {
|
||||
const submitOnEnter = this.getProp('submitOnEnter');
|
||||
if (!submitOnEnter && this.type !== 'textarea') {
|
||||
preventDefault(event);
|
||||
}
|
||||
|
||||
|
@ -434,6 +434,7 @@ export default {
|
||||
| scroll-to-error `v2.5.2` | Whether to scroll to the error field when validation failed | _boolean_ | `false` |
|
||||
| show-error `v2.6.0` | Whether to highlight input when validation failed | _boolean_ | `true` |
|
||||
| show-error-message `v2.5.8` | Whether to show error message when validation failed | _boolean_ | `true` |
|
||||
| submit-on-enter `v2.8.3` | Whether to submit form on enter | _boolean_ | `true` |
|
||||
|
||||
### Data Structure of Rule
|
||||
|
||||
@ -462,7 +463,7 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get Form instance and call instance
|
||||
| submit | Submit form | - | - |
|
||||
| validate | Validate form | _name?: string_ | _Promise_ |
|
||||
| resetValidation | Reset validation | _name?: string_ | - |
|
||||
| scrollToField `v2.8.2` | Scroll to field | _name: string, alignToTop: boolean_ | - |
|
||||
| scrollToField `v2.8.3` | Scroll to field | _name: string, alignToTop: boolean_ | - |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -469,6 +469,7 @@ export default {
|
||||
| scroll-to-error `v2.5.2` | 是否在提交表单且校验不通过时滚动至错误的表单项 | _boolean_ | `false` |
|
||||
| show-error `v2.6.0` | 是否在校验不通过时标红输入框 | _boolean_ | `true` |
|
||||
| show-error-message `v2.5.8` | 是否在校验不通过时在输入框下方展示错误提示 | _boolean_ | `true` |
|
||||
| submit-on-enter `v2.8.3` | 是否在按下回车键时提交表单 | _boolean_ | `true` |
|
||||
|
||||
> 表单项的 API 参见:[Field 组件](#/zh-CN/field#api)
|
||||
|
||||
@ -501,7 +502,7 @@ export default {
|
||||
| submit | 提交表单,与点击提交按钮的效果等价 | - | - |
|
||||
| validate | 验证表单,支持传入`name`来验证单个表单项 | _name?: string_ | _Promise_ |
|
||||
| resetValidation | 重置表单项的验证提示,支持传入`name`来重置单个表单项 | _name?: string_ | - |
|
||||
| scrollToField `v2.8.2` | 滚动到对应表单项的位置,默认滚动到顶部,第二个参数传 false 可滚动至底部 | _name: string, alignToTop: boolean_ | - |
|
||||
| scrollToField `v2.8.3` | 滚动到对应表单项的位置,默认滚动到顶部,第二个参数传 false 可滚动至底部 | _name: string, alignToTop: boolean_ | - |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -12,6 +12,10 @@ export default createComponent({
|
||||
scrollToError: Boolean,
|
||||
validateFirst: Boolean,
|
||||
errorMessageAlign: String,
|
||||
submitOnEnter: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
validateTrigger: {
|
||||
type: String,
|
||||
default: 'onBlur',
|
||||
|
Loading…
x
Reference in New Issue
Block a user