elementui 修改el-dialog样式

方案一、(如果添加append-to-body属性,则此方案不生效)

              在<el-dialog>外层添加一个父盒子比如class='batch-box',然后在style scoped中用::v-deep();     具体代码如下:

               .batch-box{

                   ::v-deep(.el-dialog__body){

                         max-height: none;

                   } 

               }

方案二、

        用文档里的自定义属性custom-class=‘batch-box’,然后在style中写(不能有scoped属性,如果不想删该属性,则在style scoped下面再写一个style即可。亲测:如果写到style scoped中即使用::v-deep也不生效~)

<style scoped lang='scss'></style>

<style>

  .dialog-batch .el-dialog__body{

     max-height: none;

  }

</style>

       

     

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于 elementuiel-dialog 组件,可以进行封装来方便使用。 封装的步骤如下: 1. 创建一个新的 Vue 组件,命名为 MyDialog。 2. 在 MyDialog 组件中引入 elementuiel-dialog 组件,并设置相关属性和事件,例如: ``` <template> <el-dialog :title="title" :visible.sync="visible" :before-close="beforeClose" :append-to-body="appendToBody" :close-on-click-modal="closeOnClickModal" :close-on-press-escape="closeOnPressEscape" :lock-scroll="lockScroll" :custom-class="customClass" :destroy-on-close="destroyOnClose" > <slot></slot> </el-dialog> </template> <script> export default { name: 'MyDialog', props: { title: { type: String, default: '' }, visible: { type: Boolean, default: false }, beforeClose: { type: Function, default: null }, appendToBody: { type: Boolean, default: false }, closeOnClickModal: { type: Boolean, default: true }, closeOnPressEscape: { type: Boolean, default: true }, lockScroll: { type: Boolean, default: true }, customClass: { type: String, default: '' }, destroyOnClose: { type: Boolean, default: false } } } </script> ``` 3. 在需要使用 el-dialog 的地方,引入 MyDialog 组件,并使用 v-model 绑定 visible 属性来控制对话框的显示和隐藏,例如: ``` <template> <my-dialog v-model="dialogVisible" title="My Dialog"> <p>Dialog content goes here.</p> </my-dialog> </template> <script> import MyDialog from '@/components/MyDialog.vue' export default { components: { MyDialog }, data() { return { dialogVisible: false } } } </script> ``` 通过这样的封装,我们可以在需要使用 el-dialog 的地方,直接使用 MyDialog 组件,而不用重复设置 el-dialog 的属性和事件。同时,也可以通过修改 MyDialog 组件的默认属性来定制化 el-dialog样式和行为。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值