2023-03-05 怎么实现一个步骤条流程图

<!-- <template>

  <div>

    <ul class="navs">

      <li>1</li>

      <li>2</li>

      <li>3</li>

      <li>4</li>

    </ul>

  </div>

</template>

<script></script>

<style>

.navs {

                height: 100px;

}

.navs li {

    padding: 0px 10px 0 30px;

    line-height: 40px;

    background: #50abe4;

    display: inline-block;

    color: #fff;

    position: relative;

}

.navs li:after {

    content: '';

    display: block;

    border-top: 20px solid #50abe4;

    border-bottom: 20px solid #50abe4;

    border-left: 20px solid #fff;

    position: absolute;

    right: -20px;

    top: 0;

}

.navs li:after {

    content: '';

    display: block;

    border-top: 20px solid transparent;

    border-bottom: 20px solid transparent;

    border-left: 20px solid #50abe4;

    position: absolute;

    right: -20px;

    top: 0;

    z-index: 10;

}

.navs li:before {

    content: '';

    display: block;

    border-top: 20px solid #50abe4;

    border-bottom: 20px solid #50abe4;

    border-left: 20px solid #fff;

    position: absolute;

    left: 0px;

    top: 0;

}

.navs li:first-child {

    border-radius: 4px 0 0 4px;

    padding-left: 25px;

}

.navs li:last-child,

.cssNavEnd {

    border-radius: 0px 4px 4px 0px;

    padding-right: 25px;

}

.navs li:first-child:before {

    display: none;

}

.navs li:last-child:after,

.cssNavEnd:after {

    display: none;

}

.navs li.active {

    background-color: #ef72b6;

}

.navs li.active:after {

    border-left-color: #ef72b6;

}

</style> -->

<template>

  <div>

    <div class="arrowsBox">

      <div v-for="(item, index) in list" :key="index" class="arrowsItem">

        <div

          class="arrows-up arrows"

          :class="{

            arrows_active: item.status === 'active',

            arrows_done: item.status === 'done',

            arrows_todo: item.status === 'todo',

          }"

        />

        <div

          class="arrows-down arrows"

          :class="{

            arrows_active: item.status === 'active',

            arrows_done: item.status === 'done',

            arrows_todo: item.status === 'todo',

          }"

        />

        <div

          class="arrows-label"

          :class="{

            arrows_label_active: item.status === 'active',

            arrows_label_done: item.status === 'done',

            arrows_label_todo: item.status === 'todo',

          }"

        >

          {{ item.label }}

          <div v-if="item.description" class="description">{{ item.description }}</div>

        </div>

      </div>

    </div>

    <button v-if="unFinish" class="btn" @click="next">下一步</button>

  </div>

</template>

<script>export default {


data() {

    return {

      unFinish: true,

      list: [

        {

          label: '1',

          description: '',

          prop: '1',

          status: 'done'

        },

        {

          label: '2',

          description: '',

          prop: '2',

          status: 'done'

        },

        {

          label: '3',

          description: '',

          prop: '3',

          status: 'active'

        },

        {

          label: '4',

          description: '',

          prop: '4',

          status: 'todo'

        },

        {

          label: '5',

          description: '',

          prop: '5',

          status: 'todo'

        },

        {

          label: '6',

          description: '',

          prop: '6',

          status: 'todo'

        },

        {

          label: '7',

          description: '',

          prop: '7',

          status: 'todo'

        },

        {

          label: '8',

          description: '',

          prop: '7',

          status: 'todo'

        },

        {

          label: '9',

          description: '',

          prop: '8',

          status: 'todo'

        },

        {

          label: '10',

          description: '',

          prop: '9',

          status: 'todo'

        },

        {

          label: '11',

          description: '',

          prop: '10',

          status: 'todo'

        },

        {

          label: '12',

          description: '',

          prop: '11',

          status: 'todo'

        },

        {

          label: '13',

          description: '',

          prop: '12',

          status: 'todo'

        },

        {

          label: '14',

          description: '',

          prop: '13',

          status: 'todo'

        }

      ]

    }

  },

  methods: {

    next() {

      for (const item of this.list) {

        if (item.status === 'active') {

          item.status = 'done'

        }

        if (item.status === 'todo') {

          item.status = 'active'

          if (this.list[this.list.length - 1].status === 'active') {

            this.unFinish = false

          }

          break

        }

      }

    }

  }

}; </script>

  <style scoped>.arrowsBox {

    display: flex;

    justify-content: center;

    height: 40px;

    margin: 20px;

    font-weight: bold;

  }

  .arrowsItem {

    position: relative;

    height: 100%;

    width: 140px;

    margin-right: 10px;

  }

  .arrows-up {

    transform: skewX(30deg);

  }

  .arrows-down {

    transform: skewX(-30deg);

  }

  .arrows {

    height: 50%;

    background: gray;

  }

  .arrows-label {

    position: absolute;

    top: 50%;

    transform: translateY(-50%);

    left: 0;

    right: 0;

    bottom: 0;

    text-align: center;

  }

  .arrows_done {

    background: #edf9ff;

  }

  .arrows_active {

    background: #009fe9;

  }

  .arrows_todo {

    background: #ebedf0;

  }

  .arrows_label_done {

    color: #009fe9;

  }

  .arrows_label_active {

    color: #fff;

  }

  .arrows_label_todo {

    color: #929393;

  }

  .btn {

    background: #009fe9;

    color: #fff;

    border: none;

    padding: 6px;

    width: 100px;

    border-radius: 4px;

    margin: auto;

    display: block;

  }</style>


实现效果如图所示
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容