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

简单实现进度条效果(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.kler.cn/a/280316.html

相关文章:

  • 2024了,Neo4j能显示节点图片吗?
  • 【架构-24】XML和JSON
  • 文心快码帮你解大厂面试题:TCP关闭连接的过程,为什么要4次挥手,为什么最大等待时间是2*MSL?
  • 【论文阅读】ColabFold: making protein folding accessible to all
  • iPhone不停重启怎么办?全面解析与解决方案
  • 对数据处理过程中,缺失值和异常值应该怎么处理?
  • Python的 数据结构
  • 效率提升好物分享2
  • SOMEIP_ETS_060: SD_Discover_Port_and_IP
  • 第20讲 动画讲解轻松学会STM32的PWM
  • FL Studio24.1.1.4239无限试用版安装包下载!快来尝鲜吧!
  • word、pdf、excel及zip加密(含示例效果及工具类)
  • SQLAlchemy 在 Python 中的同步与异步操作及CRUD实现指南
  • 【面试问题汇总】
  • Spring 源码解读:逐步实现 IoC 容器,深入理解 Spring 核心原理
  • 自动化运维:Ansible、Puppet、Chef工具对比与实战
  • MySQL的安装配置教程
  • 服务器机柜是什么意思?
  • AGI系列(8)零门槛信息抓取利器打造,免费自动化抓取推特上的热点内容
  • C#WinFrom 中实现可自定义按钮和事件的消息提示框