目标以外关闭

1、
$("body").click(function(event){
                if(!$(event.target).closest("#graphContainer")[0]){
                    that.propertiesShowWin.setVisible(false);//关闭事件
                }
            })
 
 
vue
 
mounted: function(){
        var that = this;
        $("body").click(function(event){
            that.mainClick(event);
        })
    },
 
mainClick: function(event) {
            var $target = $(event.target);

            if (!$target.closest(".paramTreePanel")[0]) {
                this.$refs.floatPanel.hide();
            }
        },
 
2、

document.addEventListener("click",e=>{
  var aa = document.getElementById("colorBtn")
  var bb = document.getElementById("colorSelectId")
  if (e.target == aa || bb.contains(e.target)) {//点击位置==目标位置 || 目标位置包含点击位置
    // console.log("zainei")
  }else{
    // console.log("zaiwai")
    this.isShowColors=false
  }
})

 
posted @ 2020-09-22 18:11  onceweb  阅读(56)  评论(0)    收藏  举报