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

【Vue】给 elementUI 中的 this.$confirm、this.$alert、 this.$prompt添加按钮的加载效果

文章目录

  • 主要使用 beforeClose 方法实现 loading 的效果
  • beforeClose MessageBox 关闭前的回调,会暂停实例的关闭
function(action, instance, done)

1. action 的值为'confirm', 'cancel''close'2. instance 为 MessageBox 实例,可以通过它访问实例上的属性和方法。
3. done 用于关闭 MessageBox 实例。
  • 具体实现:(this.$confirm、this.$alert、 this.$prompt实现方法一样)
this.$prompt('名称', '新建表单', {
  confirmButtonText: '确定',
  cancelButtonText: '取消',
  beforeClose: async (action, ctx, close) => {
  	// 如果非确认按钮事件,则直接关闭弹窗
    if (action !== 'confirm') {
      close();
      return;
    }
    // confirmButtonLoading 是在 elementUI-message-box下的 main.vue 文件中封装的参数
    ctx.confirmButtonLoading = true;
    try {
      // ctx.inputValue 获取 input 输入框的值
      await this.createApi(ctx.inputValue);
      // 提交成功后关闭窗口
      close();
    } catch (error) {}
    ctx.confirmButtonLoading = false;
  },
});
  • 实现前:
    在这里插入图片描述
  • 实现后:
    在这里插入图片描述

http://www.kler.cn/a/37356.html

相关文章:

  • 简单爬虫项目练习
  • spring中的扩展点解析以及实践使用
  • Jmeter上传文件接口测试
  • Blazor前后端框架Known-V1.2.4
  • 基于51单片机的红外测温系统的设计与实现
  • 基于Tensorflow来重现GPT v1模型
  • 跨站请求伪造(CSRF)
  • 大屏项目也不难
  • iOS 验证一下配置provisioning file有没有生效,
  • 《TCP IP网络编程》第三章
  • css实现按钮圆角渐变样式
  • Python爬虫需要那些步骤 ?
  • Pycharm安装 leetcode 插件
  • Stable Diffusion 用2D图片制作3D动态壁纸
  • 图扑 AR 技术应用与管理:施工建造、机柜扫描、办公室导航解决方案
  • 安全防御 --- SSL VPN
  • 【阅读笔记】Rapid, Detail-Preserving Image Downscaling
  • QT各种控件常用样式表qss示例
  • (30)精准降落和悬停(IRLock)
  • echarts_柱状图+漏斗图