<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>遮罩</title>
</head>
<style>
#abb {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.5);
}
.zhezhao {
width: 300px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
}
.x {
float: right;
cursor: pointer;
}
</style>
<body>
<div id="add">
<button @click="changeShow">开始把</button>
<div id="abb" v-if="seen">
<div class="zhezhao">
<span class="x" @click="changehide">X</span>
</div>
</div>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var add = new Vue({
el: '#add',
data: {
seen: false,
},
methods: {
changeShow() {
this.seen = true
},
changehide() {
this.seen = false
}
}
})
</script>
</html>