1、el-button

<el-button type="primary" @click="submit('former')" native-type="submit">立即登录</el-button>

2、el-input

<el-input v-model="form.user" @keyup.enter.native="submit('form')"></el-input>

3、input

<input v-model="form.name" placeholder="昵称" @keyup.enter="submit">

4、键盘监测

$(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>

 

Logo

前往低代码交流专区

更多推荐