随笔 - 27,  文章 - 0,  评论 - 1,  阅读 - 18063

个人网站
https://kuangyx.cn
开源地址
gitee https://gitee.com/tomiaa/vue2-steps-progress
github https://github.com/tomiaa12/vue2-steps-progress

预览

preview

安装

npm i vue2-steps-progress

开始

main.js

import stepsProgress from 'vue2-steps-progress'
Vue.use(stepsProgress);

or

import stepsProgress from 'vue2-steps-progress'
export default {
  components: {
    stepsProgress,
  }
}

模板

currentProgress

prop type default
currentProgress Number 0
<stepsProgress :currentProgress='50' />

preview

lineBackground

<stepsProgress 
:currentProgress='50' 
lineBackgroundColor='#ccc'
lineForeground='green'
/>

preview

prop type default
lineBackgroundColor String #dcdcdc
lineForeground String #019879

startLocation && endLocation

<stepsProgress
:currentProgress='30'
:startLocation='20'
:endLocation='90'
></stepsProgress> 
prop type default
startLocation Number 0
endLocation Number 100

startLocation 是整个进度条起始的百分比位置

endLocation 是整个进度条结束的百分比位置

currentProgress 是 startLocation 至 endLocation 中间的百分比

preview

demo-1-step

<stepsProgress
    :currentProgress='30'
    :steps="[{
    progress: 0,
    showRound: true,
    text: 'Have to declare'
    },{
    progress: 100,
    showRound: true,
    text: 'completed'
    }]"
    :currentStep='1'
    roundWidth='1.5em'
></stepsProgress>

preview

prop type default
steps Array
currentStep Number 0
roundWidth string 1em

roundWidth

圆半径

currentStep

currentStep 是 当前进行到step的下标, currentStep之前的圆点会点亮。

steps

<stepsProgress
:steps="[{
    progress: 100, 
    // 当前圆点距离整个进度条的left位置, 范围:0-100

    showRound: true, // 显示圆点 

    text: 'completed', // 圆点下方的文字,没有则不显示 
    foreground: 'red', // 圆点点亮的颜色 
    backgroundColor: '#000', // 圆点背景色
}]"
></stepsProgress>

demo2

<stepsProgress
    :currentProgress='90'
    :steps="[{
        progress: 10,
        showRound: true,
        text: 'Have to declare'
        },{
        progress: 25,
        showRound: true,
        text: 'Have been concluded'
        },{
        progress: 90,
        showRound: true,
        text: 'completed'
    }]"
    :startLocation='25'
    :endLocation='90'
    :currentStep='2'
></stepsProgress>

preview

demo3-slot

<template>
  <div class="demo">
    <stepsProgress
    :currentProgress='currentProgress'
    :steps="[{
      progress: 10,
      showRound: true,
      text: 'Have to declare'
    },{
      progress: 25,
      showRound: true,
      text: 'Have been concluded'
    },{
      progress: 58,
      showRound: false,
      text: 'under construction'
    },{
      progress: 90,
      showRound: true,
      text: 'completed'
    }]"
    :startLocation='25'
    :endLocation='90'
    :currentStep='2'
    >
      <template>
        <div class="slot-currentProgress">
          {{currentProgress}}
        </div>
      </template>
      <template #text='{item}'>
        <span v-if="item.text == 'under construction'" class="text">
          {{item.text}} <span style="color:red">icon</span>
        </span>
        <span v-else class="text">
          {{item.text}}
        </span>
      </template>
    </stepsProgress>
  </div>
</template>
<script>
import stepsProgress from 'vue2-steps-progress'
export default {
  components: {
    stepsProgress,
  },
  data() {
    return {
      currentProgress: 10
    }
  },
}
</script>
<style scoped>
.demo{
  width: 1000px;
  height: 50px;
  margin: 100px auto;
}
.slot-currentProgress{
  position: relative;
  background-color: rgb(1, 152, 121);
  width: 2em;
  border-radius: 50%;
  line-height: 2;
  color: white;
}
.slot-currentProgress::before{
  content: '';
  position: absolute;
  bottom: -.2em;
  left: 50%;
  width: 1em;
  height: 1em;
  background-color: inherit;
  z-index: -1;
  transform:  translateX(-50%) rotate(-45deg);
}
.text{
  position: absolute;
  font-size: 0.16rem;
  top: 120%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}
</style>

preview

posted on   tomiaa  阅读(1281)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示