当前位置: 首页 > news >正文

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

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

以下代码基于vue2,

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

在这里插入图片描述

<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>

http://www.mrgr.cn/news/9551.html

相关文章:

  • 品味生活的艺术 ——《晚酌的流派》推荐
  • Burp Suite、Wireshark与Fiddler:三款网络工具深度解析与比较
  • 【JAVA】后端开发中的数据结构:基础知识与应用场景
  • 深度学习分类:交叉熵
  • Linux云计算 |【第二阶段】SECURITY-DAY5
  • Python编码系列—Python中的Web安全防护:深入探索SQL注入与XSS攻击
  • 基于深度学习的可持续发展模型
  • 优化学习管理:Moodle和ONLYOFFICE文档编辑器的完美结合
  • easypoi模板导出word多页导出加强版
  • 【目标检测】模型评估指标
  • clickhouse-neighbor 坑爹的排序
  • npm install 安装报错解决指南
  • C#高级进阶---关于插件开发(初版)
  • 字节跳动-生活服务-java后端-一面
  • 深入理解 Vue 3 的双向绑定原理与实现
  • stm32—ADC
  • 深入探索C11标准:全面提升C语言的关键新特性与应用
  • 安捷伦色谱仪器LabVIEW软件替换与禁运配件开发
  • [新手入门]1台电脑+1个电视+2个软件(sunshine+moonlight) 解决黑神话悟空没有hdmi线的痛...
  • 功能测试与自动化测试详解