首页 前端知识 【Vue】给 elementUI 中的 this.$confirm、this.$alert、 this.$prompt添加按钮的加载效果

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

2024-01-30 10:01:41 前端知识 前端哥 933 515 我要收藏

文章目录

  • 主要使用 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;
},
});
复制
  • 实现前:
    在这里插入图片描述
  • 实现后:
    在这里插入图片描述
转载请注明出处或者链接地址:https://www.qianduange.cn//article/848.html
评论
还可以输入200
共0条数据,当前/页
发布的文章

我喜欢别人的老婆怎么办

2024-02-12 00:02:58

如何治疗hpv

2024-02-12 00:02:27

如何治疗灰指甲

2024-02-12 00:02:07

如何治疗前列腺炎

2024-02-12 00:02:42

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!