vue步骤条

在这里插入图片描述

<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>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值