麻烦帮忙看下是什么原因呢 谢谢
checkForm() {
if (this.checkName() && this.checkPwd()) {
console.log("发送请求,执行登录业务");
//发送post请求 传递两个参数 username password
this.axios
.post("/login", `username=${this.name}&password=${this.pwd}`)
.then((res) => {
console.log(res);
if(res.data.code==200){//登录成功
this.$toast('登录成功');
//提交mutations修改登录状态
this.$store.commit('loginOK',this.name);
//把islogin和name存入sessionStorage
sessionStorage.setItem('islogin',true);
sessionStorage.setItem('name',this.name);a
this.$router.push('/');
}else{//登录失败
this.$toast('账户或密码输入错误');
}
});
}
},
返回的res数据是怎么样的?提示什么?
最好不要用两个=号,===200
截图只看到了 res.status = 200
没有看到 res.data.code = 200
还有,这post传参写成key=value&ke=value
是怎么回事呢
说明rea.dat.code不等于200你打印一下看卡。应该是取值错误