目标以外关闭
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
}
})

浙公网安备 33010602011771号