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

相关推荐
抓不住时间的沙2 分钟前
butterfly主题美化,打造属于自己的个性博客
java·开发语言·前端·javascript·node.js·github
嘟嘟07171 小时前
顺时针螺旋填充 n×n 矩阵:手撕 generateMatrix 的四个 for 循环
javascript·算法·面试
weixin_BYSJ19871 小时前
springboot技能与工具共享小程序---附源码29657
java·javascript·spring boot·python·小程序·django·php
张元清1 小时前
React useSessionStorage Hook:刷新不丢、只属于当前标签页的状态 (2026)
前端·javascript·react.js
weixin_BYSJ19871 小时前
flask民族服饰饰品商城小程序---附源码37399
java·javascript·spring boot·python·小程序·django·php
xiaominlaopodaren2 小时前
three.js最小地图运行时(一):视图状态
javascript·gis·three.js
Orange_sparkle2 小时前
从五个 TypeScript 文件看懂 Coding Agent:一次 nano-pi 学习复盘
javascript·学习·typescript
摸鱼研究员2 小时前
neverthrow,ts 中优雅的异常处理方案
前端·javascript
烬羽2 小时前
求第 K 大,为什么反而要用最小堆?
javascript·数据结构·算法
jingchao19982 小时前
Cannot read properties of null (reading ‘insertBefore‘)
前端·javascript·vue.js