father and son call
The parent component defines whether the popup layer is displayed
AnimationsPopup: false
Label judgment pass value
<BoxShowPopup
v-show="AnimationsPopup"
:visible.sync="AnimationsPopup"
/>
The click event assigns true to AnimationsPopup, hides the scroll bar page and prohibits sliding
open() {
this.AnimationsPopup = true
var mo = function (e) {
e.preventDefault()
}
document.body.style.overflow = 'hidden'
document.addEventListener('touchmove', mo, false) //禁止页面滑动
},
add mask layer
Label under big label
<div :class="[{ introduced: AnimationsPopup }]"></div>
scss
.introduced {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.9);
z-index: 90;
transition: all 0.15s linear;
}
The subcomponent receives the value
props: {
visible: Boolean
},
close popup
A scroll bar appears on the click event to enable sliding
closes() {
this.$emit('update:visible', false)
var mo = function (e) {
e.preventDefault()
}
document.body.style.overflow = '' //出现滚动条
document.removeEventListener('touchmove', mo, false)
},
big label
<div
:visible="visible"
@update:visible="$emit('update:visible', $event)"
>