退出登录
1:这个功能比较简单,接收下拉列表中的 command参数,如果参数的值为logout,就调用退出登录接口,
2:判断验证如果code为1就移除存在session中的username
3:this.$router.replace跳转到首页面
async handleCommand(command){
if(command==="logout"){
let res = await this.$http.get("/api/user/logout");
console.log(res)
//验证接口
if(res.data.code===1){
//从session中移除username
sessionStorage.removeItem("username")
this.$message.success(res.data.message)
//跳转到首页面
this.$router.replace("/login")
}
}
}