<template>
<div class="test">
<div class="stepBox">
<div class="item">
<div class="stepItem" :class="{ item5: index == 4, active: item.stepIndex <= activeIndex }"
v-for="(item, index) in listData.list" :key="index">
<div class="cont">{{ item.title }}</div>
<div class="triangle"
:class="{ triangle_2: index >= 4, triangle_3: index >= 5, triangle_4: index == 5, triangle_5: index == 3, triangle_6: index == 4, activeTriangle: item.stepIndex <= activeIndex }">
</div>
</div>
</div>
</div>
<div class="bu">
<button @click="lastStep">上一步</button>
<button class="step" @click="nextStep">下一步</button>
</div>
</div>
</template>
<script setup>
import { ref, reactive } from 'vue'
const activeIndex = ref(1) //判断进行到哪一步
const listData = reactive({
list: [
{
stepIndex: 1,
title: '项目1'
},
{
stepIndex: 2,
title: '项目2'
},
{
stepIndex: 3,
title: '项目3'
},
{
stepIndex: 4,
title: '项目4'
},
{
stepIndex: 5,
title: '项目5'
},
{
stepIndex: 9,
title: '项目9'
},
{
stepIndex: 8,
title: '项目8'
},
{
stepIndex: 7,
title: '项目7'
},
{
stepIndex: 6,
title: '项目6'
}
]
})
const nextStep = () => {
activeIndex.value += 1;
}
const lastStep = () => {
activeIndex.value -= 1;
}
</script>
<style lang="scss" scoped>
.test {
padding-top: 100px;
padding-left: 100px;
}
.bu {
margin-top: 50px;
.step {
margin-left: 40px;
}
}
.stepBox {
width: 800px;
height: 300px;
border-radius: 0px 150px 150px 0px;
border: 2px dotted #DDDDDD;
border-left: 0;
position: relative;
.item {
position: absolute;
display: flex;
align-content: space-between;
top: -40px;
width: 90%;
flex-wrap: wrap;
height: 380px;
}
}
.stepItem {
width: 80px;
height: 80px;
background: #DDDDDD;
border-radius: 50%;
margin-left: 18%;
position: relative;
display: flex;
align-items: center;
justify-content: center;
.triangle {
position: absolute;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 30px solid #DDDDDD;
right: -100%;
transform: translateY(-50%);
top: 50%;
}
// 下方小三角的朝向
.triangle_2 {
rotate: 180deg;
top: -20px;
}
.triangle_3 {
left: -100%;
right: auto;
}
// 消除最后一个小三角
.triangle_4 {
display: none;
}
.triangle_5 {
top: 81px;
right: -45px;
rotate: 48deg;
}
.triangle_6 {
top: 89px;
right: 81px;
rotate: 131deg;
}
.activeTriangle {
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 30px solid skyblue;
}
}
.stepItem:nth-child(5n+1) {
margin-left: 0;
}
.item5 {
position: absolute;
right: calc(-10% - 40px);
transform: translateY(-50%);
top: 50%;
}
.active {
background: skyblue;
}
</style>
vue步骤条
最新推荐文章于 2025-02-11 00:00:04 发布