Open
Description
需要在用户离开当前页面之前,提示用户。
我阻止了路由跳转了,但是选项卡已经销毁掉了。
有什么方法阻止用户关闭选项卡吗?
path: src/main-components/tags-page-opened.vue
closePage (event, name) {
let pageOpenedList = this.$store.state.app.pageOpenedList;
let lastPageObj = pageOpenedList[0];
if (this.currentPageName === name) {
let len = pageOpenedList.length;
for (let i = 1; i < len; i++) {
if (pageOpenedList[i].name === name) {
if (i < (len - 1)) {
lastPageObj = pageOpenedList[i + 1];
} else {
lastPageObj = pageOpenedList[i - 1];
}
break;
}
}
} else {
let tagWidth = event.target.parentNode.offsetWidth;
this.tagBodyLeft = Math.min(this.tagBodyLeft + tagWidth, 0);
}
this.$store.commit('removeTag', name);
this.$store.commit('closePage', name);
pageOpenedList = this.$store.state.app.pageOpenedList;
localStorage.pageOpenedList = JSON.stringify(pageOpenedList);
if (this.currentPageName === name) {
this.linkTo(lastPageObj);
}
}
这里是直接预先关闭了选项卡,在跳路由。
能不能改改调路由成功之后,在关闭选项卡