干货之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();
}
}
};
页:
[1]