vue封装通用弹窗commonDialog

本文介绍了一个自定义的对话框组件commonDialog,包含标题、内容区域和父组件如何通过ref进行交互,设置标题和显示状态。组件使用了Vue.js并附带了SCSS样式,适合前端开发中展示弹窗或通知。
<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
### CommonDialog 的定义及其在 IT 技术中的用途 `CommonDialog` 是一种用于创建标准对话框的组件,通常应用于图形用户界面 (GUI) 开发中。它允许开发者轻松调用预定义的标准窗口,例如文件打开/保存对话框、颜色选择器或字体选择器等[^1]。 #### 1. **CommonDialog 的主要功能** `CommonDialog` 提供了一种简单的方式来显示常见的 Windows 对话框,而无需手动设计这些复杂的 UI 组件。以下是其常见用途: - 文件操作:提供文件浏览和选择的功能,支持多选以及自定义过滤条件。 - 颜色选取:帮助用户从一组预设的颜色列表中挑选所需的颜色。 - 字体设置:让用户调整文本样式,包括字体大小、粗细和其他属性。 #### 2. **实现方式** 在不同的开发环境中,`CommonDialog` 可能有不同的实现形式: - **Windows Forms (.NET Framework)** 在 .NET 中,可以通过继承 `System.Windows.Forms.CommonDialog` 类来扩展并定制自己的对话框行为。该类本身是一个抽象基类,无法直接实例化,但提供了许多子类如 `OpenFileDialog`, `SaveFileDialog`, 和 `ColorDialog` 等。 ```csharp using System; using System.Windows.Forms; public class ExampleForm : Form { private OpenFileDialog openFileDialog = new OpenFileDialog(); public ExampleForm() { openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; Button openButton = new Button { Text = "Open File", Dock = DockStyle.Top }; openButton.Click += OpenButtonClick; this.Controls.Add(openButton); } private void OpenButtonClick(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { MessageBox.Show($"Selected file: {openFileDialog.FileName}"); } } } ``` - **Electron 应用程序** 对于跨平台桌面应用框架 Electron 来说,虽然原生 API 不直接包含 `CommonDialog` 这一概念,但它可以借助 Node.js 模块或者第三方库模拟类似的交互体验。 ```javascript const { dialog } = require('electron').remote; dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'], }).then(result => { console.log(`Files selected: ${result.filePaths}`); }); ``` #### 3. **与其他技术的关系** 尽管上述讨论集中在 GUI 编程领域内的具体实践上,但从更广泛的视角来看,像迁移学习这样的高级算法研究也可能间接影响未来人机接口的设计思路[^2]。然而目前阶段两者之间并无直接联系。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值