半环形进度条(vue+element)

<template>
  <div class="elCircle-progress">
    <el-progress
      class="progress-position"
      type="dashboard"
      :percentage="percentage"
      :color="colors"
    ></el-progress>
    <div :style="{'color':fontColor}" class="chaoji-po">{{describePer}}</div>
    <div>
      <el-button-group>
        <el-button type="success" icon="el-icon-minus" @click="decrease"></el-button>
        <el-button type="warning" icon="el-icon-plus" @click="increase"></el-button>
      </el-button-group>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      percentage: 10,
      colors: [
        { color: "#f56c6c", percentage: 20 },
        { color: "#e6a23c", percentage: 40 },
        { color: "#5cb87a", percentage: 60 },
        { color: "#1989fa", percentage: 80 },
        { color: "#6f7ad3", percentage: 100 }
      ],
      fontColor: "",
      describePer:'',
    };
  },
  mounted(){
    this.checkColor();
  },
  methods: {
    increase() {
      this.percentage += 10;
      if (this.percentage > 100) {
        this.percentage = 100;
      }
      this.checkColor();
    },
    checkColor(){
      if (this.percentage <= 100) {
        this.fontColor = "#6f7ad3";
        $('.el-progress__text').css('color','#6f7ad3');
        this.describePer = '超级棒';
      }
      if (this.percentage < 80) {
        this.fontColor = "#1989fa";
        $('.el-progress__text').css('color','#1989fa');
        this.describePer = '很棒';
      }
      if (this.percentage < 60) {
        this.fontColor = "#5cb87a";
        $('.el-progress__text').css('color','#5cb87a');
        this.describePer = '一般';
      }
      if (this.percentage < 40) {
        this.fontColor = "#e6a23c";
        $('.el-progress__text').css('color','#e6a23c');
        this.describePer = '差';
      }
      if (this.percentage <= 20) {
        this.fontColor = "#f56c6c";
        $('.el-progress__text').css('color','#f56c6c');
        this.describePer = '很差';
      }
      if (this.percentage <= 10) {
        this.fontColor = "red";
        $('.el-progress__text').css('color','red');
        this.describePer = '非常差';
      }
    },
    decrease() {
      this.percentage -= 10;
      if (this.percentage < 0) {
        this.percentage = 0;
      }
      this.checkColor();
    }
  }
};
</script>

<style lang="less">
.elCircle-progress {
  .el-progress--circle .el-progress__text,
  .el-progress--dashboard .el-progress__text {
    font-size: 30px !important;
    top: 40%;
  }
}
</style>
<style lang="less">
.elCircle-progress {
  .progress-position {
    margin: 200px 0 20px 0;
    position: relative;
  }
  .chaoji-po {
    position: relative;
    top: -70px;
    left: 0;
    color: red;
  }
}
</style>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值