vue 点击div以外的其他区域隐藏
HTML代码:
<div class="show-dialog" @click="showDialog" ref="showPanel"> ..... </div>
js代码:
mounted () { document.addEventListener('mouseup',(e) =>{ let tree = this.$refs.showPanel if (tree) { if (!tree.contains(e.target)) { this.isShowDialog = false; } } }) }