css 前端实现通过css动画实现进度条动态加载效果

在这里插入图片描述

效果图

在这里插入图片描述

代码

CommonProcess.vue 进度条动态加载组件代码

<!-- 进度条组件 -->
<template>
  <div class="common_process">
    <div v-for="(item, index) in dataList" :key="processType + index" class="common_process_item">
      <div class="common_process_item_dept cyan">
        <div>
          <span class="common_process_item_dept_index">NO.{
  { index + 1 }}</span>
          {
  { item[bmmcField] }}
        </div>
        <div v-if="processType === 'jysg'">{
  { item[slField] | noDataFilter }}</div>
      </div>
      <div class="common_process_item_line">
        <div
          class="common_process_item_line_process"
          :style="{ '--width': (item[slField] / total) * 100 + '%' }"
        />
      </div>
    </div>
  </div>
</template>

<script>
export default {
     
  name: 'CommonProcess',
  components: {
     },

  props: {
     
    processType: {
     
      type: String,
      // required: true
      default: 'jysg'
    },
    dataList: {
     
      type: Array,
      // required: true
      default: () => {
     
        return [...Array(10).keys()]
          .map((num) => {
     
            return {
     
              bmmc: '部门' + (num + 1),
              sl: num
            }
          })
          .reverse()
      }
    },
    total: {
     
      type: [Number, String],
      // required: true
      default: [...Array(10).keys()].reduce((a, b) => a + b, 0)
    },
    bmmcField: {
     
      type: String,
      default: 'bmmc'
    },
    slField: {
     
      type: String,
      default: 'sl'
    }
  }
}
</script>

<style lang='scss' scoped>
.common_process {
     
  padding: 0 10px;
  &_item {
     
    padding: 7px 0;
    &_dept {
     
      display: flex;
      justify-content: space-between;
      margin-bottom: 5px;
      padding-right: 5px;
      font-size: 13px;
      &_index {
     
        padding: 2px 3px;
        border-radius: 3px;
        background: linear-gradient(90deg, #236cdc 0%, #00c0ff 100%);
        font-weight: bold;
        color: #fff;
      }
    }
    &_line {
     
      height: 8px;
      background-color: rgba(64, 158, 255, 0.1);
      border-top-right-radius: 8px;
      border-bottom-right-radius: 8px;
      &_process {
     
        position: relative;
        width: var(--width);
        height: 100%;
        background: linear-gradient(90deg, #236cdc 0%, #00c0ff 100%);
        animation: move 1s; /* 【主要代码】添加动画 */

        @keyframes move {
       /* 【主要代码】添加动画 */
          0% {
     
            width: 0%;
          }
          100% {
     
            width: var(--width);  /* 【主要代码】宽度不固定,需要计算,通过 style 属性传入 --width */
          }
        }

        &::after {
     
          content: '';
          position: absolute;
          top: -2px;
          right: 0;
          width: 6px;
          height: 12px;
          border-radius: 2px;
          background-color: #fff;
          box-shadow: 0 0 10px #faad14;
        }
      }
    }
  }
}
</style>

使用 “进度条动态加载” 组件

<template>
	<CommonProcess v-if="select === 'ybsg'" />
</template>

<script>
import CommonProcess from './CommonProcess'

export default {
     
  name: 'Accident',
  components: {
     
    CommonProcess
  },
}
</script>

相关推荐

  1. css动画旋转效果实现

    2024-01-20 00:46:01       54 阅读
  2. dom元素+CSS实现阶梯动画效果

    2024-01-20 00:46:01       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-20 00:46:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-20 00:46:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-20 00:46:01       82 阅读
  4. Python语言-面向对象

    2024-01-20 00:46:01       91 阅读

热门阅读

  1. es-删除字段-实测

    2024-01-20 00:46:01       46 阅读
  2. 2024年华数杯国际赛文心一言解题思路B题 光伏电

    2024-01-20 00:46:01       51 阅读
  3. 我的创作纪念日

    2024-01-20 00:46:01       59 阅读
  4. 基于强化学习的航线规划算法

    2024-01-20 00:46:01       61 阅读
  5. springboot minio 工具类,一站式解决

    2024-01-20 00:46:01       56 阅读
  6. 黑马C++125-关系运算符重载-==

    2024-01-20 00:46:01       56 阅读
  7. OpenHarmony—Linux之系统调用

    2024-01-20 00:46:01       46 阅读
  8. linux上面hadoop配置集群

    2024-01-20 00:46:01       49 阅读