首页 |  我的博客 |  查看该博主内容分类 | 

Vue el-form回车想提交表单数据,但会刷新页面的解决办法

原因

W3C 标准中有如下规定

When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a requestto submit the form.

即:当一个 form 元素中只有一个输入框时,在该输入框中按下回车应提交该表单。

解决办法

如果希望阻止这一默认行为,可以在el-form标签上添加 @submit.native.prevent

posted @ 2023-03-08 09:09  Z哎呀  阅读(437)  评论(0)    收藏  举报