Home > Web Front-end > Vue.js > body text

How to close the pop-up window in vuejs

藏色散人
Release: 2023-01-13 00:45:25
Original
4503 people have browsed it

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>
Copy after login

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;
                  }
              }
        }
    },
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!