Open GitHubXiaoSiyuan opened 4 years ago
可以用抓包工具看下哈
{"msg":"登录成功!","code":"200","success":true,...
submitForm(loginForm) {
this.$refs[loginForm].validate((valid) => {
if (valid) {
this.loading = true;
this.postRequest('/doLogin', this.loginForm).then(resp => {
this.loading = false;
if (resp.success) {
this.db.save("USER", resp.user);
let path = this.$route.query.redirect;
this.$router.replace((path == '/' || path == undefined) ? '/home' : path);
}
})
} else {
console.log('error submit!!');
return false;
}
});
}
如果success返回true ,正常是可以跳转到home页的
1. {"msg":"登录成功!","code":"200","success":true,"user":{"userId":"admin","deptId":1,"deptName":null,"userName":"不懂温柔","sortNumber":99,"freezeStatus":false,"phoneNumber":"13800138000","roles":["管理员","内容编辑"],"headImgUrl":"attachment/2020-03-16/ad50149fd04f4a32a0cf8030a4a3e03a.jpeg"},"url":"system"} 2.
Failed to load resource: net::ERR_NETWORK_ACCESS_DENIED
[WDS] Disconnected!
sockjs.js?6707:1606 GET http://192.168.1.68:9000/sockjs-node/info?t=1591626493302 net::ERR_NETWORK_ACCESS_DENIED
看着响应结果说明接口没有问题,我这边到没有遇到这个这个问题,那个 sockjs.js 的错误貌似不会影响到跳转...
不过解决思路可以考虑用排除法,比如先确定请求结果有没有正常获取,如果正常那就往下排除,看看使用路由跳转有没有问题。
有时间你可以调试下哈,比如在post请求后打印下响应结果,然后直接路由跳转试试呢
this.postRequest('/doLogin', this.loginForm).then(resp => {
console.log(resp);
this.$router.replace('/home');
})
好的,我的需求还没有做完,有时间我再调试
用户名输入adi 点击提交,然后就是登陆成功,不跳转