From a522d09734844fffec1c7a4f65159bfb6226c2d3 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Thu, 28 Jan 2021 14:26:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=84=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8C=89=E4=B8=8B=E5=9B=9E=E8=BD=A6=E9=94=AE=E9=83=BD=E4=BC=9A?= =?UTF-8?q?=E9=80=80=E5=9B=9EContral=E9=A1=B5=E9=9D=A2=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/Login.vue | 41 ++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/web_src/src/components/Login.vue b/web_src/src/components/Login.vue index 160197a4..2a918865 100644 --- a/web_src/src/components/Login.vue +++ b/web_src/src/components/Login.vue @@ -29,14 +29,13 @@ export default { } }, created(){ - var that = this; - document.onkeydown = function(e) { - var key = window.event.keyCode; - if (key == 13) { - that.login(); + var that = this; + document.onkeydown = function(e) { + var key = window.event.keyCode; + if (key == 13) { + that.login(); + } } - } - }, methods:{ @@ -70,6 +69,7 @@ export default { if (res.data == "success") { that.$cookies.set("session", {"username": that.username}) ; //登录成功后 + that.cancelEnterkeyDefaultAction(); that.$router.push('/'); }else{ that.isLoging = false; @@ -84,18 +84,23 @@ export default { that.$message.error(error.response.statusText); that.isLoging = false; }); - - - }, - setCookie: function (cname, cvalue, exdays) { - var d = new Date(); - d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); - var expires = "expires=" + d.toUTCString(); - console.info(cname + "=" + cvalue + "; " + expires); - document.cookie = cname + "=" + cvalue + "; " + expires; - console.info(document.cookie); - }, + setCookie: function (cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); + var expires = "expires=" + d.toUTCString(); + console.info(cname + "=" + cvalue + "; " + expires); + document.cookie = cname + "=" + cvalue + "; " + expires; + console.info(document.cookie); + }, + cancelEnterkeyDefaultAction: function() { + document.onkeydown = function(e) { + var key = window.event.keyCode; + if (key == 13) { + return false; + } + } + } } }