vue实现自定义步骤条

  • 首先看一下实现的效果:
    vue实现自定义步骤条_第1张图片
  • 来看看实现过程:

公共插件


<template>
  <div class="stepOut">
    <ul>
      <li class="stepItem" v-for="(stepItem, index) in stepInfo.list" :key="index">
        
        <div :class="stepInfo.step >= index+1 ? 'icon active':'icon'">div>
        
        <div :class="stepInfo.step >= index+2 ? 'line lineActive':'line'" v-show="index!==stepInfo.list.length-1">div>
        
        <p class="stepStatus">{{stepItem.status}}p>
        
        <p class="statusTime">{{stepItem.statusTime}}p>
      li>
    ul>
  div>
template>

<script>
export default {
  name: 'steps',
  props: {
    // 传递步骤参数
    stepInfo: {
      type: Object,
      default: function () {
        return {
          list: [],
          step: 0
        }
      }
    }
  }
}
script>

<style lang="less" scoped>
.stepOut {
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: center;
  .stepItem {
    width: 260px;
    height: 70px;
    float: left;
    font-family: SimSun;
    font-size: 16px;
    text-align: center;
    position: relative;
    .icon {
      width: 13px;
      height: 13px;
      border-radius: 50%;
      background: rgba(226, 226, 226, 1);
      margin: 0 auto;
      position: relative;
      z-index: 888;
    }
    .active {
      background-color: green;
    }
    .line {
      position: absolute;
      top: 6px;
      left: 50%;
      border-bottom: 1px dashed rgba(3, 2, 2, 0.7);
      width: 260px;
      z-index: 111;
    }
    .lineActive {
      border-bottom: 1px solid green;
    }
    .stepStatus {
      color: rgba(87, 87, 87, 1);
      line-height: 36px;
    }
    .statusTime {
      color: rgba(87, 87, 87, 1);
      opacity: 0.5;
    }
  }
}
style>

使用

<template>
  <div class="main">
    <Steps :stepInfo="stepInfo">Steps>
  div>
template>

<script>
import Steps from '@/components/Steps'
export default {
  components: { Steps },
  data () {
    return {
      stepInfo: {
        list: [{ status: '提现申请提交成功,令额冻结', statusTime: '2019-11-8 12:12:12' },...],
        step: 2
      }
    }
  }
}
script>

你可能感兴趣的:(vue,vue,自定义步骤条)