在使用键盘监听键盘事件时直接绑定没有任何反应。  

vue 监听键盘事件

直接在生命周期中进行绑定就可以了。

created:function(){
let _this = this;
document.onkeydown = function(e){
let _key = window.event.keyCode;
if(_key === 13){
_this.login(1);
}
}
},

相关文章: