You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>模态框示例</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<style>
.modal {
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
background-color: #fff;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
</style>
</head>
<body>
<div id="app">
<button @click="tanchuang">创建房间</button>
<div class="modal" v-if="isModalVisible">
<div class="modal-content">
<span @click="closeModal" style="cursor:pointer; float:right;">&times;</span>
<h2>创建房间</h2>
<p>这里是房间创建的内容...</p>
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data: {
isModalVisible : false
},
methods: {
tanchuang() {
this.isModalVisible = true; // 打开模态框
},
closeModal() {
this.isModalVisible = false; // 关闭模态框
}
}
});
</script>
</body>
</html>