From ff578a8bdd4db7e5ae5466b99789874b2bc7f141 Mon Sep 17 00:00:00 2001 From: sakuya <81883387@qq.com> Date: Mon, 30 May 2022 20:18:38 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20scContextmenu=20=E5=8F=B3=E9=94=AE?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=20=E5=9C=A8=E7=89=B9=E5=AE=9A=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E4=B8=AD=E6=97=A0=E6=B3=95=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/scContextmenu/index.vue | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/components/scContextmenu/index.vue b/src/components/scContextmenu/index.vue index 8e1c8f02..7f0a72e4 100644 --- a/src/components/scContextmenu/index.vue +++ b/src/components/scContextmenu/index.vue @@ -1,10 +1,10 @@ @@ -34,17 +34,10 @@ }, watch: { visible(value) { - var _this = this; - var cm = function(e){ - let sp = _this.$refs.contextmenu - if(sp&&!sp.contains(e.target)){ - _this.closeMenu() - } - } if (value) { - document.body.addEventListener('click', e=>cm(e)) + document.body.addEventListener('click', this.cm, true) }else{ - document.body.removeEventListener('click', e=>cm(e)) + document.body.removeEventListener('click', this.cm, true) } } }, @@ -52,6 +45,12 @@ }, methods: { + cm(e){ + let sp = this.$refs.contextmenu + if(sp&&!sp.contains(e.target)){ + this.closeMenu() + } + }, menuClick(command){ this.closeMenu() this.$emit('command', command) @@ -89,7 +88,7 @@