vue dialog里面再加dialog 导致页面被遮挡

在里面一个el-dialog 加上 append-to-body

<el-dialog append-to-body></el-dialog>

Vue实现对话框页面有多种方法,以下是其一种常见的实现方式: 1. 首先,在Vue组件创建一个对话框组件,可以使用第三方库如Element UI或者自定义组件。 2. 在对话框组件的样式,设置其为绝对定位,并将left和top属性设置为50%,同时使用transform属性将其平移至屏幕心。 3. 在对话框组件的父组件,使用条件渲染的方式控制对话框的显示与隐藏。 4. 在父组件,使用CSS的flex布局或者其他方式将对话框组件居显示。 下面是一个示例代码: ```vue <template> <div class="parent"> <button @click="showDialog">打开对话框</button> <dialog-component v-if="isDialogVisible" @close="closeDialog"></dialog-component> </div> </template> <script> import DialogComponent from './DialogComponent.vue'; export default { components: { DialogComponent, }, data() { return { isDialogVisible: false, }; }, methods: { showDialog() { this.isDialogVisible = true; }, closeDialog() { this.isDialogVisible = false; }, }, }; </script> <style scoped> .parent { display: flex; justify-content: center; align-items: center; height: 100vh; } .dialog-component { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } </style> ``` 在上述示例,点击按钮会触发`showDialog`方法,将`isDialogVisible`设置为true,从而显示对话框组件。对话框组件的样式使用绝对定位,并通过设置left和top属性为50%,使用transform属性将其居显示。父组件使用flex布局将对话框组件居显示。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值