scriptexport default name logout methods logOut this$confirm确定退出吗 提示 confirmButtonText 确定 cancelButtonText 取消 type warning then = thisclearToken;
这段代码存在一个问题,即在清除服务器token时,发送的请求头中的token是放在Headers字段中,而实际上应该放在headers字段中。因此,服务器无法正确获取到token并进行注销操作,导致无法退出登录。
正确的代码应该是将Headers改为headers,即:
axios.post("http://nn.nncoding.icu:8080/api/logout", {
headers: {
token: token
}
}).then(response => {
console.log(response);
}).catch((error) => {
console.log(error);
})
这样修改后,服务器就能正确获取到token并进行注销操作,实现退出登录的功能。
原文地址: http://www.cveoy.top/t/topic/h9CO 著作权归作者所有。请勿转载和采集!