How to close the pop-up window in vuejs: 1. Create the html code structure; 2. Determine whether the clicked area is in ".mask_popup"; 3. Close it through "hideMaskPopup(e){...}" Just pop up the window.
The operating environment of this article: windows7 system, vue2.5.17 version, DELL G3 computer.
How to close the pop-up window in vuejs?
vue.js Click on the area outside the pop-up window to close the pop-up window
Click on the pop-up window Code structure for closing the pop-up window in the area outside the window
html:
<p class="publish_mask_popup" @click="hideMaskPopup" v-show="showMaskPopup"> <p class="mask_popup"> 内容代码..... </p> </p>
js:
data(){ showMaskPopup:false }, methods: { hideMaskPopup(e){ let mask = document.querySelector(".mask_popup"); if (mask) { if (!mask.contains(e.target)) {//判断所点击的区域是否在.mask_popup中 this.showMaskPopup = false; } } } },
Achievement effect:
The above is the detailed content of How to close the pop-up window in vuejs. For more information, please follow other related articles on the PHP Chinese website!