需要一个移动端全屏弹窗
项目是用vant实现的,在vant框架里面没找到合适的全屏弹窗组件。
干脆自己写一个算了。
就弄了个简洁版的全屏弹窗。
需求比较简单,在全屏弹窗里面打开指定url,左上角标题,右上角关闭按钮。
没有遮罩、拖拽,没有其它依赖,适合懒人使用。
来个🌰
HTML部分:
<div v-if="state.showDetailFlag" class="modal-container" @click.stop>
<div class="modal-header">
<span class="modal-title">详情</span>
<van-icon name="cross" size="24px" class="close-icon" @click="state.showDetailFlag = false"/>
</div>
<iframe
:src="state.detailUrl"
width="100%"
height="calc(100% - 56px)"
style="border:none;"
></iframe>
</div>
js部分:
<script setup>
const state = reactive({
showDetailFlag: false,
detailUrl: ''
});
</script>
样式:
<style>
.modal-container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: white;
z-index: 9999;
display: flex;
flex-direction: column;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px;
background-color: #f7f8fa;
border-bottom: 1px solid #ebedf0;
}
.modal-title {
font-size: 18px;
font-weight: bold;
}
.close-icon {
cursor: pointer;
}
.modal-container iframe {
width: 100%;
height: 100%;
border: none;
}
</style>