1. 程式人生 > 其它 >vue 進度條 元件

vue 進度條 元件

技術標籤:vue

<template>
  <div class="step-face">
    <div v-for="(item, index) in stepArray" class="step" :class="index+1>value?'will-step':index+1==value?'doing-step':index+1<value?'complete-step':''" :key="index">
        <span class="icon-step" v-if="value<=index+1">{{index+1}}</span>
         <span class="icon-step" v-else></span>
        <span class="step-text" >{{item}}</span>
        <span class="step-line"></span> 
    </div>
  </div>
</template>

<script>
export default {
  props: {
    //步驟數字
    value: {
      default: 0,
      type: Number,
      required: true,
    },
    //步驟陣列
    stepArray: {
      type: Array,
      required: true,
    }
  }
}
</script>


<style scoped lang="scss">

  .step-face{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .step-face .icon-step{
    display: inline-block;
    width: 32px;
    height: 32px;
    margin-right: 8px;
    text-align: center;
    line-height: 32px;
    font-size: 16px;
  }
  .step{
    display: flex;
    align-items: center;
  }
  .step-face .step:not(:last-child) .step-line{
    display: inline-block;
    width: 190px;
    height: 1px;
    background: rgba(0,0,0,.15);
    margin-left: 10px;
    flex: 1;
  }
  .step .step-text{
    font-size: 16px;
    font-family: PingFangSC-Regular,PingFang SC;
    font-weight: 400;
    color: rgba(0,0,0,.65);
  }
  .step-face .step:not(:last-child){
    margin-right: 17px; 
    flex: 1;
  }
  .step-face .will-step .icon-step{
    border: 1px solid rgba(0,0,0,.15);
    color: rgba(0,0,0,.15);
    border-radius: 50%;
  }
  .step-face .doing-step .icon-step{
    background: #4c68ef;
    border-radius: 50%;
    color: #fff;
    border-color: #4c68ef;
  }
  .step-face .doing-step .step-text{
    font-weight: bold;
    color: #333;
  }
  .step-face .complete-step .icon-step{
    background: url('../../../assets/schooladmin/icondon.png') no-repeat;
    background-size: 100%;
  }
</style>
 <step :stepArray="steparr" :value="status"></step>