Home >Web Front-end >Vue.js >How to close the pop-up window in vuejs

How to close the pop-up window in vuejs

藏色散人
藏色散人Original
2021-09-03 11:53:304614browse

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.

How to close the pop-up window in vuejs

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:
How to close the pop-up window in vuejs

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn