vue手写一个步骤条steps

html 复制代码
<div
 class="step"
    v-for="(item, itemInd) in stepInfo"
    :key="item.title"
    :class="{ finish: itemInd < activeIndex, process: itemInd == activeIndex }">
    <div class="step-header">
        <div class="step-line"></div>
        <div class="step-icon"></div>
    </div>
    <div class="step-main">
        <div class="step-title">{{ item.title }}</div>
        <div class="tag-list">
            
        </div>
    </div>
</div>
js 复制代码
const activeIndex = ref(2);
const stepInfo = [
    {
        title: '证前管理',
        icon: 'folder',
    },
    {
        title: '污染排放',
        icon: 'monitor',
    },
    {
        title: '执法监管',
        icon: '执法',
    },
    {
        title: '环境安全',
        icon: '环境安全',
    },
    {
        title: '公共监督',
        icon: 'person2',
    },
];
css 复制代码
.step {
    display: flex;
    position: relative;

    .step-header {
        position: relative;
        flex-grow: 0;
        width: 12px;
        .step-line {
            width: 2px;
            top: 4px;
            bottom: -4px;
            left: 5px;
            position: absolute;
            // border-color: currentColor;
            // background-color: var(--el-text-color-placeholder);
            background: repeating-linear-gradient(
                to bottom,
                #949494,
                #949494 3px,
                transparent 3px,
                transparent 6px
            );
        }
        .step-icon {
            position: relative;
            z-index: 1;
            display: inline-flex;
            justify-content: center;
            align-items: center;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            font-size: 14px;
            box-sizing: border-box;
            background: #949494;
        }
    }
    .step-main {
        padding-left: 10px;
        flex-grow: 1;
        // min-height: 200px;
        margin-bottom: 20px;
        .step-title {
            font-size: 16px;
            margin-bottom: 12px;
        }
    }
    // 完成状态 line和icon都点亮
    &.finish {
        .step-line {
            background: repeating-linear-gradient(
                to bottom,
                #1890ff,
                #1890ff 3px,
                transparent 3px,
                transparent 6px
            );
        }
        .step-icon {
            background: var(--el-color-primary); // 这里 --el-color-primary具体值应该是#1890ff
        }
    }
    // 当前状态 只点亮icon
    &.process {
        .step-icon {
            background: var(--el-color-primary);
        }
    }

    &:last-child {
        .step-line {
            display: none;
        }
    }
}
html 复制代码
:class="{ finish: itemInd < activeIndex, process: itemInd == activeIndex }"

关键点activeIndex 控制步骤条点亮,当前步骤为process ,小于activeIndex的状态为finish

相关推荐
里欧跑得慢1 天前
17. Flutter Hero动画实现:让界面过渡更加优雅
前端·css·flutter·web
cn_mengbei1 天前
用React Native开发OpenHarmony应用:Reanimated共享元素过渡
javascript·react native·react.js
kyriewen1 天前
前端测试:别为了100%覆盖率而写测试,那是自欺欺人
前端·javascript·单元测试
Data_Journal1 天前
如何使用cURL更改User Agent
大数据·服务器·前端·javascript·数据库
掌心向暖RPA自动化1 天前
如何获取网页某个元素在屏幕可见部分的中心坐标影刀RPA懒加载坐标定位技巧
java·javascript·自动化·rpa·影刀rpa
竹林8181 天前
wagmi v2 多链钱包切换:一个 Uniswap 仿盘项目让我踩了三天坑
前端·javascript
你也向往长安城吗1 天前
最快的 JavaScript navmesh pathfinding3d 算法。
javascript
滕青山1 天前
在线PDF拆分工具核心JS实现
前端·javascript·vue.js
凯瑟琳.奥古斯特1 天前
Redis是什么及核心特性
前端·css·redis·缓存
DFT计算杂谈1 天前
VASP官方教程 TRIQS DFT+DMFT计算教程
运维·css·自动化·html·css3