禁止回车提交
场景:当form中只有一个input的时候,input输入内容并提交,会触发form提交,不论form中是否有submit(如果是在webform中,感觉就像是重新加载了一次页面)
解决:加上一个form,然后在form中指定@submit.native.prevent="search"
<el-form ref="form" :model="{}" label-width="80px" @submit.native.prevent="search">
<h3 style="margin-top:5px;">会员位置查询</h3>
<div style="text-align:center; margin-top:20px;">
<input v-model="cardNum" type="text" class="inputText" style="width:300px; border-radius:5px; height:32px;" placeholder="会员卡号"/>
<button type="button" class="btn btn-default " @click="search">查询</button>
</div>
</el-form>
$emit
事件发起
this.$emit('event-name',{});
事件处理
<my-component @event-name="onEventHandle"></my-component>