标签:none img nta contain pre dde 点击 contains lse
诀窍1:使用el.contains(e) 来判断点击的区域
诀窍2:使用mouseup
诀窍3:完成之后,移除事件
showpopover (e) { this.popover = !this.popover var closePopover = (event) => { if (!this.$refs.popover.contains(event.target)) { this.popover = false document.body.removeEventListener(‘mouseup‘, closePopover) } } document.body.addEventListener(‘mouseup‘,closePopover) }
标签:none img nta contain pre dde 点击 contains lse
原文地址:https://www.cnblogs.com/CyLee/p/9049184.html