el-button
<el-button type="primary" @click="submit('former')" native-type="submit">登录</el-button>
el-input
<el-input v-model="form.user" @keyup.enter.native="submit('form')"></el-input>
input
<input v-model="form.name" placeholder="昵称" @keyup.enter="submit">
JQ写法
$(document).keydown(function (event) {
event = event ? event : (window.event ? window.event : null);
if (event.keyCode == 13) {
$submit.trigger('click');
}
});
vue下可能会出现提交后,链接地址中间段无故多出了很多字符串的情况,需要使用: @submit.native.prevent
<el-form id="former" @submit.native.prevent>
<!-- some code -->
</el-form>