Skip to content

Commit

Permalink
修复tag盒子上右键弹窗在特定情况下无法关闭的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhaoguan committed Apr 10, 2020
1 parent 17b3612 commit 02fa4bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/page/index/tags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ export default {
tag() {
this.setActive();
},
contextmenuFlag() {
window.addEventListener("mousedown", this.watchContextmenu);
contextmenuFlag(contextmenuShow) {
// 只在右键菜单显示的时候监听鼠标点击事件
if (contextmenuShow) {
window.addEventListener("mousedown", this.watchContextmenu);
}
}
},
computed: {
Expand All @@ -74,12 +77,11 @@ export default {
}
},
methods: {
watchContextmenu() {
if (!this.$el.contains(event.target) || event.button !== 0) {
watchContextmenu(e) {
if (!this.$el.contains(e.target)) {
this.contextmenuFlag = false;
window.removeEventListener("mousedown", this.watchContextmenu);
}
window.removeEventListener("mousedown", this.watchContextmenu);
},
handleContextmenu(event) {
let target = event.target;
Expand Down

0 comments on commit 02fa4bd

Please sign in to comment.