简单实现进度条效果(vue2)

如果用echarts或者其他图表来写个进度条有点大材小用,所以直接简单html、js写一下就可以;

以下代码基于vue2,

部分代码来自国内直连GPT/Claude镜像站

javascript 复制代码
<template>
  <div class="progress-container">
    <div class="progress-item" v-for="(item, index) in progressData" :key="index">
      <div class="label">{{ item.label }}</div>
      <div class="progress-bar">
        <div class="progress" :style="{ width: item.value + '%', backgroundColor: item.color }">
          <span class="value">{{ item.value }}%</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ProgressChart',
  data() {
    return {
      progressData: [
        { label: '当前值', value: 15, color: '#ff4757' },
        { label: '设计值', value: 8, color: '#2ed573' }
      ]
    }
  },
}
</script>

<style scoped>
.progress-container {
  background-color: #1e3a5f;
  padding: 10px;
}
.progress-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.label {
  width: 60px;
  color: #fff;
  font-size: 14px;
}
.progress-bar {
  flex-grow: 1;
  height: 20px;
  background-color: #2c4d6f;
  margin: 0 10px;
  position: relative;
}
.progress {
  height: 100%;
  transition: width 0.5s ease-in-out;
  position: relative;
}
.value {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 14px;
}
</style>
相关推荐
m0_69484557几秒前
UVdesk部署教程:企业级帮助台系统实践
服务器·开发语言·后端·golang·github
泉飒1 分钟前
C2001: 常量中有换行符-QT解决办法-逆向思路
开发语言·qt
cch89185 分钟前
Vue-Element-Admin快速上手指南
前端·javascript·vue.js
ghie90908 分钟前
基于学习的模型预测控制(LBMPC)MATLAB实现指南
开发语言·学习·matlab
咚为12 分钟前
Rust 经典面试题255道
开发语言·面试·rust
十六年开源服务商18 分钟前
家庭装修公司网站方案策划2026
java·开发语言
Mr_Xuhhh21 分钟前
深入理解Java高级特性:反射、枚举与Lambda表达式实战指南
开发语言·python
XiYang-DING24 分钟前
【Java】TOP-K问题
java·开发语言
枫叶丹425 分钟前
【HarmonyOS 6.0】Navigation组件新特性
开发语言·华为·harmonyos
格林威28 分钟前
GigE Vision 多相机同步终极检查清单(可直接用于项目部署)
开发语言·人工智能·数码相机·机器学习·计算机视觉·视觉检测·工业相机