Vue项目中实现回车登录

1
2
3
4
5
6
7
8
9
10
created(){
let that = this;
document.onkeypress = function(e) {
var keycode = document.all ? event.keyCode : e.which;
if (keycode == 13) {// 回车键对应值为13
that.login();// 登录方法名
return false;
}
};
}