Explorar o código

解决点击其他地方关闭不了弹窗问题

zhuliu hai 1 ano
pai
achega
25b4887d61
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      src/utils/model/RichText/index.vue

+ 7 - 1
src/utils/model/RichText/index.vue

@@ -77,7 +77,13 @@ export default {
         that.showCustomMenu(event)
     });
     // 当点击任意地方或者按下ESC键时,隐藏菜单
-    window.onclick = this.hideCustomMenu
+    // window.onclick = this.hideCustomMenu
+    window.addEventListener('click',function(event){
+      var customMenu = that.$refs.customMenu
+      if (event.target != customMenu && !customMenu.contains(event.target)) {
+          customMenu.style.display = "none";
+      }
+    })
     window.onkeydown = this.checkKeyPress
   },
   methods: {