vue 點擊彈窗以外的其他區域可以關閉彈窗


html:

<div class="orgTree" @click.stop="stopMp" ref="treeWrap">
    .....
</div>

js:

mounted () {
    let _this = this;
    document.addEventListener('mouseup',(e) =>{
        let tree = this.$refs.treeWrap
        if (tree) {
          if (!tree.contains(e.target)) {
            this.isShowTree =false
          }
        }
      })      
}

 

備注: 同一個頁面有多個相同的彈窗也可以通過


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM