vue项目里登录界面实现回车登录
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');//登录函数
}
}
}
该博客介绍了如何在Vue项目中通过监听键盘事件实现登录界面的回车键登录功能,使用了window.event或e.code判断条件。
299

被折叠的 条评论
为什么被折叠?



