【element-ui】el-progress 前端自定义进度条

27 篇文章 1 订阅

去年写了一篇antd-design-vue的自定义进度条,现在记录下element-ui的自定义进度条

效果如下,实现方式都是以弹窗的形式打开

在这里插入图片描述
1、给按钮绑事件

  <el-button
            style="height: 23px"   
            @click="checkBack(scope.row)"
            type="text"
            >撤回
          </el-button>

2、弹窗内加进度条,text-inside将进度条描述置于进度条内部,stroke-width 进度条的宽度,单位 px,percentage 百分比(必填)

<!--进度条 -->
    <el-dialog
      :title="operaScheduleTitle"
      :visible.sync="operaScheduleDialog"
      width="30%"
      left
    >
      <el-progress
        :text-inside="true"
        :stroke-width="26"
        :percentage="percentage"
      ></el-progress>
    </el-dialog>

3、data中定义需要的变量

 operaScheduleDialog: false,
operaScheduleTitle: "撤回中,请耐心等待!",
 percentage: 0,

4、按钮事件

  checkBack(row) {
  
        if (!this.submitIds.length) {
          this.$message.warning("请先选择需要撤回的单据!");
          return;
        }
        obj = { id: this.submitIds };
    
      //打开进度条弹窗
      this.operaScheduleDialog = true;
      this.percentage = 0;     
      //调接口,启动定时器,接口获取完,销毁定时器
      BackPlan(obj, (process) => {
      //创建定时器,实现进度条
        this.increaseTimer();
      })
        .then((res) => {
          this.increaseTimerEnd();
          this.msgSuccess("撤回成功");
          this.getList();
        })
        .catch((err) => {
          this.operaScheduleDialog = false;
        });
    },

5、计时器相关事件

    increaseTimer() {
      var that = this;
      that.timeStart = setInterval(function () {
        if (that.percentage < 90) {
          that.percentage += 5;
        }
        if (that.percentage > 100) {
          that.percentage = 100;
        }
      }, 300);
    },
    increaseTimerEnd() {
      var that = this;
      that.percentage = 100;
      that.operaScheduleDialog = false;
      clearInterval(this.timeStart);
    },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值