实现点击页面其他地方,隐藏div(vue)(Click elsewhere on the page to hide div (Vue))

document.addEventListener('click',function(e){
    if(e.target.className!='usermessage'){
        that.userClick=false;
    }
})
给最外层的div加个点击事件 @click="userClick=false"
给点击的元素上面加上:@click.stop="userClick=!userClick"
————————
document.addEventListener('click',function(e){
    if(e.target.className!='usermessage'){
        that.userClick=false;
    }
})
给最外层的div加个点击事件 @click="userClick=false"
给点击的元素上面加上:@click.stop="userClick=!userClick"