window.history.pushState(null, null, "#"); // 在打开弹窗的方法里面写这个
export default {
name: "set",
data() {
return {
popstanub: -1,
}
},
components: {
detailsheader
},
beforeDestroy(){
Dialog.close()
},
created() {
},
destroyed(){
window.removeEventListener('popstate',this.popState,false)
},
activated() {
window.addEventListener('popstate',this.popState,false)
},
methods: {
popState(){
if(this.popstanub == 1){
Dialog.close()
}else{
this.$router.go(-1);
}
},
back() {
history.back();
},
async logout() {
this.popstanub = 1;
Dialog.confirm({
title: '标题',
message: '确定退出登录吗?',
}).then(() => {
this.popstanub = -1
this.$store.commit("updateToken", "");
this.$store.commit("updateLogin", false);
this.$router.replace("/login")
}).catch(() => {
this.popstanub = -1
})
window.history.pushState(null,null,'#')
}
}
};