Vue+Element UI el-progress进度条内显示自定义数字及文字

需求

进度条内展示 具体的数字值,进度条外展示 百分比数值

在这里插入图片描述

数据

data() {
    return {
      reNum: 3214,
      rePer:40,
      warmPer: 40,
      warmNum:2132,
  }
 }

因为样式要求,显示的百分数也是自己写的哈 ,没有用进度条自带的

代码

    <div class="pick">
        <div class="proItem warmPk">
            <el-progress
             :text-inside="true"
             :stroke-width="20"
             :show-text="true"
             :percentage="warmPer"
             :format="format(warmNum)"
             color="#fff"></el-progress>
             <div class="pro-num proTwoBK">{{ warmPer }}%</div>
         </div>
         <div class="proItem rePick">
             <el-progress
             :text-inside="true"
             :show-text="true"
             :stroke-width="20"
             :percentage="rePer"
             :format="format(reNum)"
             color="#fff"></el-progress>
         <div class="pro-num proBK">{{ rePer }}%</div>
      </div>
  </div>

js方法

  format(row) {
      return () => {
        return row ? row : 0;
      };
    },

css样式代码

   .pick {
        margin-top: 1vh;

        .proItem {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-left: 1.5vh;
            width: 100%;
        }

        .pro-num {
            font-weight: 700;
            font-size: 1.9vh;
            width: 19%;
        }

        .proBK {
            color: #40E9FF;
        }

        .proTwoBK {
            color: #F57A47
        }



        .warmPk {
            ::v-deep.el-progress-bar__inner {

                background: #F67700 !important;
            }
        }

        .rePick {
            margin-top: 1.3vh;

            ::v-deep.el-progress-bar__inner {
                background: #49AAE5 !important;
            }
        }

        ::v-deep.el-progress-bar__outer {
            background: #353536 !important;
        }

        ::v-deep.el-progress-bar {
            width: 100% !important;

        }

        ::v-deep.el-progress-bar__inner {
            border-radius:10px !important;
        }

        ::v-deep.el-progress {
            text-align: center !important;
            width: 81% !important
        }

        ::v-deep.el-progress-bar__innerText {
            font-size: 1.4vh !important;
            font-weight: 700 !important;
            color: #fff !important;
        }
    }

2.使用插槽

<template>
  <el-progress
    :percentage="50"
    :stroke-width="26"
    text-inside
    :format="formatText"
  >
    <template #text>
      <span>自定义文字</span>
    </template>
  </el-progress>
</template>
 
<script>
export default {
  methods: {
    formatText(percentage) {
      // 如果需要,可以在这里根据percentage值来动态显示文字
      return `${percentage}% 自定义文字`;
    }
  }
};
</script>
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值