项目场景:element+vue 后台管理系统
今天使用elementUI的表单添加数据出现,点击回车键,页面自动刷新,并且在原路由里面加了一个?,解决办法如下:
<el-form :inline="true" @submit.native.prevent>
</el-form>
el-from 加上 @submit.native.prevent
具体是参考element-ui文档解决的
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 request to submit the form.
即:当一个 form 元素中只有一个输入框时,在该输入框中按下回车应提交该表单。如果希望阻止这一默认行为,可以在 标签上添加 @submit.native.prevent。
原文:https://blog.csdn.net/qq_32340877/article/details/80272155