vue+element 键盘回车事件导致页面刷新的问题

背景

今天发现输入框输入内容后回车就会刷新页面

解决

  <el-form  :inline="true" @submit.native.prevent>
   </el-form>
    
    
  • 1
  • 2

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。

        <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/markdown_views-ea0013b516.css">
            </div>

背景

今天发现输入框输入内容后回车就会刷新页面

解决

  <el-form  :inline="true" @submit.native.prevent>
   </el-form>
  
  
  • 1
  • 2

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。

        <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/markdown_views-ea0013b516.css">
            </div>

猜你喜欢

转载自blog.csdn.net/qw943571775/article/details/81902737