问题:input输入框输入内容,按键盘上的回车按钮,会刷新界面
解决方法:
1.如果回车时有方法需要调用,在调用方法的时候加上@keyup.enter.native
2.如果在input上加上@keyup.enter.native,第一次回车时还是会刷新界面,在el-from上加上 @submit.native.prevent
<el-form :inline=“true” class=“searchTerm demo-form-inline” @submit.native.prevent>
<el-input clearable v-model=“queryTableName” placeholder=“请输入关键字” @keyup.enter.native=“querybtand(queryTableName)” >
即: 当一个 form 元素中只有一个输入框时,在该输入框中按下回车应提交该表单。如果希望阻止这一默认行为,可以 在 标签上添加 @submit.native.prevent。