温故而知新 js 点击空白处关闭气泡

诀窍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)
}

温故而知新 js 点击空白处关闭气泡温故而知新 js 点击空白处关闭气泡

上一篇:makesfx.exe (Make SFX (Self-extracting archive))


下一篇:js学习笔记:操作iframe