//监听页面销毁之前
beforeDestroy() {
window.removeEventListener(
"popstate",
() => {
if (this.showPop) {
this.showPop = false;
} else {
this.$router.go(-1);
}
},
false
);
},
//使用了keep-alive进行页面缓存
//可以写在mounted函数里
activated() {
window.addEventListener(
"popstate",
() => {
if (this.showPop) {
this.showPop = false;
}
},
false
);
},
//打开弹窗
getPop() {
this.showPop = true;
window.history.pushState(null, null, "#");
},