怎么阻止用户不关闭选项卡
- Dominant language
- Vue
- Stars
- 16.4k
- Forks
- 4.7k
- PR merge metrics
- No merged PRs in 30d
Description
需要在用户离开当前页面之前,提示用户。
我阻止了路由跳转了,但是选项卡已经销毁掉了。
有什么方法阻止用户关闭选项卡吗?
path: src/main-components/tags-page-opened.vue
```javacript
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);
}
}
```
这里是直接预先关闭了选项卡,在跳路由。
能不能改改调路由成功之后,在关闭选项卡
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main-components/tags-page-opened.vue and trace closePage through linkTo and the route transition. Verify the route succeeds before removing the tag and closing the page, while preserving the existing behavior for unsuccessful navigation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100