如何给弹窗加loading

本文介绍了如何在ElementUI的el-descriptions或弹窗内的el-form组件中添加全屏加载状态,并自定义加载提示文本,提升用户体验。
摘要由CSDN通过智能技术生成

效果:

直接在el-descriptions或者你弹窗里面用到的el-form中加v-loading="fullscreenLoading" element-loading-text="拼命加载中"

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
可以使用异步编程的方式来解决element比较耗时的方法loading弹窗的问题。具体实现方式是在方法执行前显示loading弹窗,然后使用异步编程的方式执行方法,方法执行完毕后关闭loading弹窗。以下是一个示例代码: ``` <template> <div> <el-button @click="handleClick">执行耗时方法</el-button> <el-dialog :visible.sync="loadingVisible"> <el-progress type="circle" :percentage="loadingPercentage"></el-progress> </el-dialog> </div> </template> <script> export default { data() { return { loadingVisible: false, loadingPercentage: 0 } }, methods: { async handleClick() { this.loadingVisible = true this.loadingPercentage = 0 const result = await this.longTimeMethod() this.loadingVisible = false console.log(result) }, longTimeMethod() { return new Promise(resolve => { setTimeout(() => { resolve('long time method result') }, 5000) }) } } } </script> ``` 在上面的代码中,我们使用了一个loadingVisible变量来控制loading弹窗的显示和隐藏,使用了一个loadingPercentage变量来控制loading进度条的进度。在handleClick方法中,我们首先将loadingVisible设置为true,然后使用异步编程的方式执行longTimeMethod方法,方法执行完毕后将loadingVisible设置为false。在longTimeMethod方法中,我们使用了Promise来模拟一个耗时的方法,方法执行完毕后返回一个结果。在实际应用中,我们可以将longTimeMethod替换为我们需要执行的耗时方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值