vue封装通用弹窗commonDialog

本文介绍了一个自定义的对话框组件commonDialog,包含标题、内容区域和父组件如何通过ref进行交互,设置标题和显示状态。组件使用了Vue.js并附带了SCSS样式,适合前端开发中展示弹窗或通知。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<template>
  <div>
    <el-dialog
      :visible.sync="commonVisible"
      :modal-append-to-body="false"
      :width="width"
      custom-class="commonDialog"
    >
      <div slot="title" class="title">
        <div class="square"></div>
        <span>{{ title }}</span>
      </div>
      <div class="MainBody">
        <slot name="bodyContent">

        </slot>
      </div>
    </el-dialog>
  </div>

</template>

<script>
export default {
  name: "commonDialog",
  components: {},
  data() {
    return {
      commonVisible: false,
      title: '111',
      width: "91.770833vw"
    }
  },
  mounted() {
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
::v-deep .commonDialog {
  background: #091C42;
  border: 1px solid rgba(0, 137, 216, 1);

  .el-dialog__header{
    padding: 0;
  }

  .el-dialog__body{
    padding-left: 0!important;
    padding-right: 0!important;
    padding-top: 0!important;
  }

  .el-dialog__headerbtn {
    top: 10px;
  }

  .el-dialog__headerbtn .el-dialog__close {
    color: #ffffff;
  }
}
.title{
  width: 100%;
  height: 0.3125rem;
  background: url("~@/assets/zlfxImages/DfxtjscImg/titleBg.png");
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: left;
  padding-left: 0.14375rem;
  overflow: hidden;
  .square{
    width: 4px;
    height: 22px;
    background: #00C6FF;
    position: absolute;
    left: 0;
  }
  span{
    font-size: 0.125rem;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #FFFFFF;
  }
}
.MainBody{
  width: 100%;
  //height: 3.75rem;
  padding: 0.125rem 0.125rem 0rem;
}
</style>

父组件调用

<commonDialog ref="xxgk">
   <div slot="bodyContent">
      
   </div>
</commonDialog>
import commonDialog from "../components/Dialog/commonDialog";

components: {commonDialog,ryfbTable},

this.$refs.xxgk.title = '详情'
this.$refs.xxgk.commonVisible = true
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值