【Element】进度条 el-progress

ElementUI

圆环不显示

大概率是因为宽度没有设置.

.el-progress {
    width: 100%
}

圆圈背景色

<el-progress type="circle" :percentage="20" class="percent"></el-progress>
// ::v-deep  .el-progress-circle__track
::v-deep  .percent  svg path:nth-child(1) {
    stroke: red;
}

::v-deep  .percent  svg path:nth-child(2) {
    stroke: yellow;
}

::v-deep  .percent .el-progress__text {
    color: blue;
}

圆圈中心文本自定义

利用position来定位,show-text=false去掉原生的文字。

<div class="percent_box">
  <el-progress type="circle" class="percent" :percentage="20"  :show-text="false"></el-progress>
  <div class="text_box">
    <p class="title">通过率</p>
    <p class="text">80%</p>
  </div>
</div>
.percent_box {
  position: relative;
  text-align: center;
  width: 200px;
}

.text_box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

圆环渐变色

<div role="progressbar" aria-valuenow="14" aria-valuemin="0" aria-valuemax="100" class="el-progress el-progress--circle">
  <div class="el-progress-circle" style="height: 136px; width: 136px;">
    <svg viewBox="0 0 100 100">
      <defs>
        <linearGradient id="blue" x1="0%" y1="0%" x2="100%" y2="0%">
          <stop offset="0%" style="stop-color:#13D59A;stop-opacity:1" />
          <stop offset="100%" style="stop-color:#32C5FF;stop-opacity:1" />
        </linearGradient>
      </defs>
        <path d="
          M 50 50
          m 0 -45
          a 45 45 0 1 1 0 90
          a 45 45 0 1 1 0 -90
          " stroke="#e5e9f2" stroke-width="9.6" fill="none" class="el-progress-circle__track" style="stroke-dasharray: 282.743px, 282.743px; stroke-dashoffset: 0px;">
        </path>
        <path d="
          M 50 50
          m 0 -45
          a 45 45 0 1 1 0 90
          a 45 45 0 1 1 0 -90
          " stroke="url(#blue)" fill="none" stroke-linecap="round" stroke-width="9.6" class="el-progress-circle__path" style="stroke-dasharray: 39.5841px, 282.743px; stroke-dashoffset: 0px; transition: stroke-dasharray 0.6s ease 0s, stroke 0.6s ease 0s;">
        </path>
    </svg>
  </div>
</div>

参考:设置el-progress渐变背景色

报错 custom validator check failed for prop "percentage"

<el-progress type="circle" :percentage="percent" class="progress"></el-progress>
created() {
  getInfo({id: this.id}).then(res => {
    if(res.code == 200) {
      this.percent = res.percent > 100 ? 100 :(res.percent < 0 ? 0 : res.percent)
    }else {
      this.percent = 0
    }
  });
},

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宾果的救星

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值