Top
Fork me on Gitee My Github

Vue -- element-ui el-input组件 回车刷新页面问题

form内只有一个输入框时,按回车会刷新页面 && 如果input有回车事件回车也会刷新页面

 <el-form ref="form" :inline="true" :model="form" label-width="100px">
   <el-input v-model="form.keyword" placeholder="筛选关键词"  class="handle-input mr10" @keyup.enter.native="search"></el-input>
 </el-form>

阻止form的默认事件,即在form上加上这句话:@submit.native.prevent

 <el-form ref="form" :inline="true" :model="form" label-width="100px" @submit.native.prevent>
    <el-input v-model="form.keyword"  placeholder="筛选关键词" class="handle-input mr10" @keyup.enter.native="search"></el-input>
 </el-form>

Element UI

posted @ 2020-10-23 14:29  lisashare  阅读(875)  评论(0编辑  收藏  举报