ps :样式不能写在scoped里面,否则失效
1. 给dialog 起个类名,custom-class="dialogStyle"
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="38%"
center
destroy-on-close
V-el-drag-dialog
V-if="dialogVisible"
append-to-body
custom-class="dialogStyle"
:before-close="handleClose"
>
<!-- formID 指的是ID -->
<indexForm
:newFormdata="newFormdata"
ref="fromViewRef"
/>
</el-dialog>
2. 直接复制粘贴此代码即可生效。
<style>
.dialogStyle {
display: flex;
flex-direction: column;
margin: 0 !important;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-height: calc(100% - 30px);
max-width: calc(100% - 30px);
}
</style>
如果dialog 内容过多要有滚动,需加下面这句
::v-deep .el-dialog .el-dialog__body{ flex:1; overflow: auto; }