Vue点击div以外的地方使div消失
<div @click="judge=true">显示</div><div v-show="judge" id="box"></div>created(){document.addEventListener("click",e=>{let box = document.getElementById("moreBox")if(!box.conta
·
<div @click="judge=true">显示</div>
<div v-show="judge" id="box"></div>
created(){
document.addEventListener("click",e=>{
let box = document.getElementById("moreBox")
if(!box.contains(e.target)){
this.judge = false
}
}
更多推荐
已为社区贡献12条内容
所有评论(0)