超简单的基于Vue2实现DIY定制的步骤条

梦想不抛弃苦心追求的人,只要不停止追求,你们会沐浴在梦想的光辉之中。再美好的梦想与目标,再完美的计划和方案,如果不能尽快在行动中落实,最终只能是纸上谈兵,空想一番。只要瞄准了大方向,坚持不懈地做下去,才能够扫除挡在梦想前面的障碍,实现美好的人生蓝图。超简单的基于Vue2实现DIY定制的步骤条,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

由于一些定制化的需求无法在网上直接找到可用插件来实现,只能DIY设计实现,如以下步骤条。

子组件【zqStep.vue】

<template>
  <div>
    <ul class="diy-steps">
      <li v-for="(item, index) in stepList" :key="index">
        <div class="diy-step">
          <div class="diy-step-line_left" v-if="index === 0 && item.status === 'undone'" :style="'background-image: linear-gradient(' + '90deg' + ', #ffffff, #bbbbbb)'"/>
          <div class="diy-step-line_left" v-if="index === 0 && item.status !== 'undone'" :style="'background-image: linear-gradient(' + '90deg' + ', #ffffff, #4cb45b)'"/>
          <div class="diy-step-line_left" v-else-if="index !== 0 && item.status === 'undone'" :style="'background-image: linear-gradient(' + '0deg' + ', #bbbbbb, #bbbbbb)'"/>
          <div class="diy-step-line_left" v-else-if="index !== 0 && item.status !== 'undone'" :style="'background-image: linear-gradient(' + '0deg' + ', #4cb45b, #4cb45b)'"/>

          <div class="diy-step-box diy-step__success" v-if="item.status === 'success'">
            <span>
              <i class="el-icon-check"></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-box diy-step__fail" v-else-if="item.status === 'fail'">
            <span>
              <i class="el-icon-close"></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-box diy-step__doing" v-else-if="item.status === 'doing'">
            <span>
              <i class=""></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-box diy-step__undone" v-else-if="item.status === 'undone'">
            <span>
              <i class=""></i>
            </span>
            <strong>{{ item.label }}</strong>
          </div>

          <div class="diy-step-line_right" v-if="index === stepList.length - 1 && item.status === 'success'" :style="'background-image: linear-gradient(' + '90deg' + ', #4cb45b, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index === stepList.length - 1 && item.status === 'fail'" :style="'background-image: linear-gradient(' + '90deg' + ', #4cb45b, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index === stepList.length - 1 && item.status === 'doing'" :style="'background-image: linear-gradient(' + '90deg' + ', #bbbbbb, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index === stepList.length - 1 && item.status === 'undone'" :style="'background-image: linear-gradient(' + '90deg' + ', #bbbbbb, #ffffff)'"/>
          <div class="diy-step-line_right" v-else-if="index !== stepList.length - 1 && item.status === 'undone' && (index + 1 <= stepList.length - 1) && stepList[index + 1].status === 'undone' " :style="'background-image: linear-gradient(' + '180deg' + ', #bbbbbb, #bbbbbb)'"/>
          <div class="diy-step-line_right" v-else-if="index !== stepList.length - 1 && item.status !== 'undone' && (index + 1 <= stepList.length - 1) && stepList[index + 1].status === 'undone' " :style="'background-image: linear-gradient(' + '180deg' + ', #bbbbbb, #bbbbbb)'"/>
          <div class="diy-step-line_right" v-else-if="index !== stepList.length - 1 && item.status !== 'undone' && (index + 1 <= stepList.length - 1) && stepList[index + 1].status !== 'undone' " :style="'background-image: linear-gradient(' + '180deg' + ', #4cb45b, #4cb45b)'"/>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: ['stepList'],
  data: () => ({
    // stepList : [
    //   {label: '准备好所有的食材', status: 'success'},
    //   {label: '把茶叶和白砂糖放入锅中', status: 'success'},
    //   {label: '将其翻炒至冒泡', status: 'fail'},
    //   {label: '加入白开水煮沸', status: 'doing'},
    //   {label: '倒入纯牛奶', status: 'undone'},
    //   {label: '滤出茶叶就好了', status: 'undone'}
    // ],
  })
}
</script>

<style lang="less">
  .diy-steps {
    width: auto;
    height: 55px;
    margin: 40px auto 0 auto;
    padding: 0;
    position: relative;
    display: table;
    font-family: "微软雅黑";
  }

  .diy-steps li {
    width: 260px;
    height: 100%;
    list-style-type: none;
    font-size: 12px;
    text-align: center;
    position: relative;
    float: left;
  }

  .diy-steps li .diy-step {
    width: 260px;
    display: inline-block;
    position: absolute;
    margin-left: -130px;
    left: 50%;
    z-index: 1;
  }

  .diy-step-line_left {
    border-bottom: 1px solid transparent;
    background-image: linear-gradient(90deg, #bbbbbb, #4cb45b);
    width:130px;
    height: 1px;
    display: inline-block;
    position: absolute;
    top: 9px;
    left: 0;
    z-index: 0;
  }

  .diy-step-line_right {
    border-bottom: 1px solid transparent;
    background-image: linear-gradient(180deg, #bbbbbb, #4cb45b);
    width:130px;
    height: 1px;
    display: inline-block;
    position: absolute;
    top: 9px;
    right: 0;
    z-index: 0;
  }

  .diy-steps li .diy-step .diy-step-box {
    position: relative;
    z-index: 1;
  }

  .diy-steps li .diy-step .diy-step-box span {
    display: block;
    width: 13px;
    height: 13px;
    border-radius: 100%;
    color: #fff;
    /* transform: scale(1.2); */
    text-align: center;
    margin: 0 auto 8px auto;
  }

  .diy-steps li .diy-step .diy-step-box span i {
    display: block;
    width: 13px;
    height: 13px;
    border-radius: 100%;
    line-height: 13px;
  }

  .diy-steps li .diy-step .diy-step-box strong {
    letter-spacing: 0.5px;
  }

  /* diy-step__success */
  .diy-step__success span {
    border: rgba(55, 171, 71, 0.2) 4px solid;
    border: rgb(215 238 218) 4px solid;
  }

  .diy-step__success span i {
    background-color: #37ab47;
  }

  .diy-step__success strong {
    color: #37ab47;
  }
  /* / diy-step__success */

  /* diy-step__fail */
  .diy-step__fail span {
    border: rgba(252, 94, 90, 0.2) 4px solid;
    border: rgb(254 223 222) 4px solid;
  }

  .diy-step__fail span i {
    background-color: #fc5e5a;
  }

  .diy-step__fail strong {
    color: #fc5e5a;
  }
  /* / diy-step__fail */

  /* diy-step__doing */
  .diy-step__doing span {
    border: rgba(94, 124, 224, 0.2) 4px solid;
    border: rgb(223 229 249) 4px solid;
  }

  .diy-step__doing span i {
    background-color: #5e7ce0;
  }

  .diy-step__doing strong {
    color: #5e7ce0;
  }
  /* / diy-step__doing */

  /* diy-step__undone */
  .diy-step__undone span {
    border: rgba(153, 153, 153, 0.2) 4px solid;
    border: rgb(235 235 235) 4px solid;
  }

  .diy-step__undone span i {
    background-color: #999999;
  }

  .diy-step__undone strong {
    color: #999999;
  }
  /* / diy-step__undone */
</style>

父页面【index.vue】

<template>
  <div>
    <ZqStep :stepList="stepList1"/>
    <ZqStep :stepList="stepList2"/>
    <ZqStep :stepList="stepList3"/>
    <ZqStep :stepList="stepList4"/>
    <ZqStep :stepList="stepList5"/>
    <ZqStep :stepList="stepList6"/>
    <ZqStep :stepList="stepList7"/>
  </div>
</template>

<script>
import ZqStep from './components/zqStep'

export default {
  components: {
    ZqStep
  },
  data: () => ({
    stepList1: [
      { label: '准备好所有的食材', status: 'doing' },
      { label: '把茶叶和白砂糖放入锅中', status: 'undone' },
      { label: '将其翻炒至冒泡', status: 'undone' },
      { label: '加入白开水煮沸', status: 'undone' },
      { label: '倒入纯牛奶', status: 'undone' },
      { label: '滤出茶叶就好了', status: 'undone' }
    ],

    stepList2: [
      { label: '准备好所有的食材', status: 'success' },
      { label: '把茶叶和白砂糖放入锅中', status: 'doing' },
      { label: '将其翻炒至冒泡', status: 'undone' },
      { label: '加入白开水煮沸', status: 'undone' },
      { label: '倒入纯牛奶', status: 'undone' },
      { label: '滤出茶叶就好了', status: 'undone' }
    ],

    stepList3: [
      { label: '准备好所有的食材', status: 'success' },
      { label: '把茶叶和白砂糖放入锅中', status: 'fail' },
      { label: '将其翻炒至冒泡', status: 'doing' },
      { label: '加入白开水煮沸', status: 'undone' },
      { label: '倒入纯牛奶', status: 'undone' },
      { label: '滤出茶叶就好了', status: 'undone' }
    ],

    stepList4: [
      { label: '准备好所有的食材', status: 'success' },
      { label: '把茶叶和白砂糖放入锅中', status: 'success' },
      { label: '将其翻炒至冒泡', status: 'fail' },
      { label: '加入白开水煮沸', status: 'doing' },
      { label: '倒入纯牛奶', status: 'undone' },
      { label: '滤出茶叶就好了', status: 'undone' }
    ],

    stepList5: [
      { label: '准备好所有的食材', status: 'success' },
      { label: '把茶叶和白砂糖放入锅中', status: 'success' },
      { label: '将其翻炒至冒泡', status: 'success' },
      { label: '加入白开水煮沸', status: 'fail' },
      { label: '倒入纯牛奶', status: 'doing' },
      { label: '滤出茶叶就好了', status: 'undone' }
    ],

    stepList6: [
      { label: '准备好所有的食材', status: 'success' },
      { label: '把茶叶和白砂糖放入锅中', status: 'success' },
      { label: '将其翻炒至冒泡', status: 'success' },
      { label: '加入白开水煮沸', status: 'success' },
      { label: '倒入纯牛奶', status: 'fail' },
      { label: '滤出茶叶就好了', status: 'doing' }
    ],

    stepList7: [
      { label: '准备好所有的食材', status: 'success' },
      { label: '把茶叶和白砂糖放入锅中', status: 'success' },
      { label: '将其翻炒至冒泡', status: 'success' },
      { label: '加入白开水煮沸', status: 'success' },
      { label: '倒入纯牛奶', status: 'success' },
      { label: '滤出茶叶就好了', status: 'success' }
    ]
  })
}
</script>

<style>

</style>

效果图:

超简单的基于Vue2实现DIY定制的步骤条

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/151145.html

(0)
飞熊的头像飞熊bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!