axios.post('/internal/user/login_from_mobile ',{
mobile: this.logPrefix+this.formInline1.mobile,
password: this.formInline1.password,
}).then((res) => {
localStorage.setItem('mobile',res.data.user.mobile);
localStorage.setItem('username',res.data.user.username);
localStorage.setItem('token',res.data.token);
localStorage.setItem('userType',res.response.user.userType);
self.$router.push('/'); //这里没有进行跳转
}).catch((error) => {
this.$Message.error(error.response.data.errorMassage);
self.modal_loading = false;
})
点击登录之后,登录接口成功返回了登录之后的数据,localstorage也成功存储了相应的值,但是路由没有进行跳转,而且会报错error中的data undifined(实际error中的信息确实得从data中获取),明明登录成功了但是走了catch的条件里。
想问下各位能帮我看出来这是什么问题吗?
已解决问题。因为在
localStorage.setItem('userType',res.response.user.userType);
这里返回的数据填写错误,所以只要有错误就会走catch语句,但是传入的参数正确,所以正常登录返回数据。