当前位置: 首页 > news >正文

element MessageBox 实现底部三个按钮或者更多按钮—开箱即用

效果图: 

思路:

使用 el-dialog组件实现的。开箱即用,可以直接拿我的代码组件直接引入 方便使用

代码:

html代码
<template><el-dialog custom-class="myConfirmation" :visible.sync="dialogVisible" :title="title" width="420px" :before-close="handleClose"><div class="dialog-content"><i style="color: #e6a23c; font-size: 24px !important; margin-left: 1px" :class="iconClass" class="icon"></i><span>{{ message }}</span></div><span slot="footer" class="dialog-footer"><el-button size="small" v-for="(button, index) in buttons" :key="index" :type="button.type" @click="handleButtonClick(button.action)">{{ button.text }}</el-button></span></el-dialog>
</template>
js代码
<script>
export default {props: {title: {type: String,default: "提示",},message: {type: String,required: true,},icon: {type: String,default: "el-icon-warning",},buttons: {type: Array,default: () => [{ text: "取消", type: "default", action: "cancel" },{ text: "确定", type: "primary", action: "confirm" },],},},data() {return {dialogVisible: true,};},computed: {iconClass() {return this.icon;},},methods: {handleClose() {this.$emit("close");},handleButtonClick(action) {this.$emit("action", action);this.dialogVisible = false;},},
};
</script>
css样式代码
<style lang="scss">
.myConfirmation {font-size: 18px;border-radius: 4px;// 修改样式让对话框水平垂直居中position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);margin: 0 !important;padding-bottom: 10px;.el-dialog__header {padding: 15px 15px 10px !important;}.el-dialog__body {padding: 10px 15px;color: #606266;font-size: 14px;}.el-dialog__footer {padding: 5px 15px 0;}.dialog-content {display: flex;align-items: center;}.icon {font-size: 24px;margin-right: 10px;}
}
</style>
 

相关文章:

  • 【MySQL】第二弹——MySQL表的增删改查(CURD))
  • 【MySQL】存储引擎 - MEMORY详解
  • 使用 CDN 在国内加载本地 PDF 文件并处理批注:PDF.js 5.x 实战指南
  • Ubuntu 安装 Nginx
  • 【hadoop】案例:Sqoop迁移仓库数据
  • OpenTelemetry 介绍
  • 【软件推荐——ScreenToGif】
  • docker 部署clickhouse
  • [数据处理] 6. 数据可视化
  • Java 17配置Jenkins
  • 基于Django和Bootstrap开发的美食推荐系统
  • 函数级重构:如何写出高可读性的方法?
  • 探讨关于智能体(Agent)结合 Dify、大语言模型(LLM)以及 Qwen-3 模型的项目或概念
  • VNC windows连接ubuntu桌面
  • Linux——Mysql数据库
  • 安全可控·高效响应|北峰智能互通矿业通信系统解决方案
  • 记录 iframe 跨域通信及安全配置
  • MariaDB 与 MySQL 的关系:从同源到分道扬镳
  • 二叉树的基本操作
  • 浅谈 Shell 脚本编程中引号的妙用
  • 泽连斯基称与特朗普通话讨论停火事宜
  • 上海交大:关注到对教师邵某的网络举报,已成立专班开展调查
  • 多地跟进官宣下调公积金贷款利率,最低降至2.1%
  • 王耀庆化身“罗朱”说书人,一人挑战15个角色
  • 潘功胜发布会答问五大要点:除了降准降息,这些政策“含金量”也很高
  • 碧桂园服务:拟向杨惠妍全资持有的公司提供10亿元贷款,借款将转借给碧桂园用作保交楼