<template>
<div ref="treeShow">
<el-tree v-show="treeShow ">...</el-tree>
</div>
</template>
document.addEventListener('click', e => {
// this.choosecapacity(e)
console.log(this.$refs.treeShow,this.$refs.treeShow.contains(e.target),e.target)
if(this.$refs.treeShow.contains(e.target)){
//this.$refs.treeShow获取dom,e.target获取当前点击的dom,判断是否包含
this.treeShow = true
}else{
this.treeShow = false
}
})
网友评论