elementplus使用el-progress进度条实现末尾自定义图片

需求:需要在进度条末尾放上ui图,效果如下
在这里插入图片描述
主要代码:这里使用的vue3和elementplus实现的

<template>
  <div class="abnormal">
    <div class="tongji" v-for="(item, index) in eventList" :key="item.id">
      <img class="img" src="@/assets/img/settle.png" alt="" />
      <span>{{ item.name }}</span>
      <div class="step">
        <el-progress
          :class="index % 2 === 0 ? 'step1' : 'step2'"
          :percentage="(item.num / 45) * 100"
          :format="format"
          :text-inside="true"
          status="exception"
        />
        <div :class="index % 2 === 0 ? 'num1' : 'num2'">
          {{ item.num }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
const eventList = ref<any>([
  { id: "1", name: "垃圾识别", num: 45 },
  { id: "2", name: "违规建筑", num: 40 },
  { id: "3", name: "河边漂浮物", num: 35 },
  { id: "4", name: "店外经营", num: 30 },
  { id: "5", name: "违建检测", num: 25 },
  { id: "6", name: "其他", num: 20 }
]);

const format = () => "";
</script>

<style scoped lang="scss">
.abnormal {
  width: 400px;
  height: 350px;
  border: 1px #036ec3 solid;
  padding: 5px 5px 0 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  .tongji {
    width: 100%;
    height: 100%;
    .img {
      width: 20px;
      height: 20px;
    }
    .step {
      width: 100%;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      .step1 ::v-deep .el-progress-bar__inner {
        width: 100%;
        background: linear-gradient(
          244deg,
          #12dbfb 50%,
          transparent 100%
        );
      }
      .step2 ::v-deep .el-progress-bar__inner {
        width: 100%;
        background: linear-gradient(
          244deg,
          #138afe 50%,
          transparent 100%
        );
      }
      .num1 {
        border-bottom: 4px #12dbfb solid;
      }
      .num2 {
        border-bottom: 4px #138afe solid;
      }
    }
  }
}
@keyframes progress {
  from {
    width: 0;
  }
  to {
  }
}
::v-deep .el-progress {
  width: 90%;
  height: 8px;
  margin-top: 10px;
  
  .el-progress-bar__inner {
    width: 85%;
    position: absolute;
    height: 5px !important;
    animation: progress 1s ease;
    background: linear-gradient( 244deg, #12dbfb 50%, transparent 100% );
  }
  .el-progress-bar__innerText {
    display: block;
    width: 20px;
    height: 35px !important;
    float: right;
    background-image: url("@/assets/img/settle.png");
    background-size: 100% 100%;
    margin: -14px -10px;
  }
  .el-progress-bar__outer {
    height: 40px !important;
    position: unset !important;
    background-color: transparent;
  }
}
</style>

  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值