去年写了一篇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、按钮事件文章来源:https://www.toymoban.com/news/detail-502251.html
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、计时器相关事件文章来源地址https://www.toymoban.com/news/detail-502251.html
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);
},
到了这里,关于【element-ui】el-progress 前端自定义进度条的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!