View层
<template>
<div>
<div class="mask" v-if="showModal" @click="showModal=false"></div>
<div class="pop" v-if="showModal">
<button @click="showModal=false" class="btn">点击出现弹框</button>
</div>
<button @click="showModal=true" class="btn">点击出现弹框</button>
</div>
</template>
数据层:
<script>
export default {
data() {
return {
showModal: false
};
}
};
</script>
样式层:
<style scoped>
.mask {
background-color: #000;
opacity: 0.3;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1
}
.pop {
background-color: #fff;
position: fixed;
top: 100px;
left: 300px;
width: calc(100% - 600px);
heigh