input框中enter键页面刷新问题
作者:互联网
在form表单中添加一个input,在input上添加@keyup.enter.native,发现输入框输入内容后回车就会刷新页面
解决办法是在form里添加 @submit.native.prevent
<el-form @submit.native.prevent > <el-form-item> <el-input v-model="name" placeholder="请输入关键词" clearable size="small" @keyup.enter.native="handleQuery" /> </el-form-item> </el-form>
当一个 form 元素中只有一个输入框时,在该输入框中按下回车应提交该表单。如果希望阻止这一默认行为,可以在 标签上添加 @submit.native.prevent。
标签:prevent,form,输入框,添加,enter,input,框中,native 来源: https://www.cnblogs.com/ywyth/p/15379460.html