这是一个登录功能,我收到“无法读取未定义的属性角色”错误:这是我的vueJs代码:
methods: {
send: function() {
this.error = null;
this.showLoader = true;
this.$http
.post("/login", new FormData(document.getElementById("LoginUser")), {
reponseType: "json"
})
.then(response =>
{
localStorage.setItem("role", response.data.data.rol);
location.href = "/";
},
fail => {
this.showLoader = false;
this.password = "";
for (let message of fail.data.data.messages) {
this.error = this.$t(
message.message.toLowerCase().replace(/ /g, "_")
);
}
}
);
}
}
我究竟做错了什么?谢谢我很久以来一直在尝试解决这个问题,但是我没有成功
根据文档vue-resource
,该response
对象没有属性data
。您正在寻找的是response.body
或者response.json()
要解析response.body
为JSON对象。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句