创意电子
标题:
干货之Vue登录页面源码,带你进入Vue源代码的天下
[打印本页]
作者:
金农码
时间:
2021-8-11 20:18
标题:
干货之Vue登录页面源码,带你进入Vue源代码的天下
Vue 聪明平台
帐号
密码
登录
export
default
{
data
:
function
() {
return
{
moduleName
:
"userInfo"
,
loginloading
:
false
,
logindesc
:
""
,
logintitle
:
""
,
ruleForm
: {
username
:
""
,
password
:
""
},
rules
: {
username
: [{
required
:
true
,
message
:
"请输入账号"
}],
password
: [{
required
:
true
,
message
:
"请输入密码"
}]
}
};
},
created
:
function
() {
var
_self
=
this
;
document
.
onkeydown
=
function
(
e
) {
if
(
window
.
event
.
keyCode
===
13
) {
_self
.
submitForm
();
}
}
},
methods
: {
submitForm
() {
const
self
=
this
;
self
.
$refs
.
ruleForm
.
validate
(
valid
=>
{
if
(
valid
) {
self
.
loginloading
=
true
;
var
u
=
self
.
ruleForm
;
var
url
=
this
.
moduleName
+
"/login?username="
+
u
.
username
+
"&password="
+
self
.
$cryptosha1
(
u
.
password
).
toString
();
self
.
$ajax
.
get
(
url
).
then
(
data
=>
{
self
.
$router
.
push
(
"/index"
);
self
.
loginloading
=
false
;
},
error
=>
{
self
.
loginloading
=
false
;
}
);
}
});
},
resetForm
() {
this
.
$refs
.
ruleForm
.
resetFields
();
}
}
};
欢迎光临 创意电子 (https://wxcydz.cc/)
Powered by Discuz! X3.4