fix(form):fix the problem that the default behavior of enter keyboard operation when the input tag is under the form tag will cause the adjacent button to be triggered

This commit is contained in:
songwanli2025@163.com 2020-06-05 18:15:21 +08:00
parent 3e65db0847
commit 9034c1781e

View File

@ -4,7 +4,8 @@
:class="{
'n-form--inline': inline
}"
@submit="onSubmit"
@submit.prevent="onSubmit"
@keydown.enter.prevent="handleEnterKeyDown"
>
<slot />
</form>
@ -113,6 +114,11 @@ export default {
formItemInstance.clearValidationEffect()
}
}
},
handleEnterKeyDown (e) {
if (e.target.tagName === 'INPUT') {
this.onSubmit(e)
}
}
}
}