vue项目里登录界面实现回车登录

全局监听enter键,是把监听事件绑定到document上,无需获取焦点之类的

created() {
    let that = this;
    document.onkeydown =function(e){
      e = window.event || e;
      if(that.$route.path=='/login'&&(e.code=='Enter'||e.code=='enter')){//验证在登录界面和按得键是回车键enter
        that.submitForm('loginForm');//登录函数
      }
    }
  }

 

posted @ 2019-04-17 11:07  只争朝夕,不负韶华  阅读(6263)  评论(2编辑  收藏  举报