Vue2+Element-UI的el-steps封装与修改样式

 

<template>
  <div>
    <!--1.设置 simple 可应用简洁风格,该条件下 align-center / description / direction / space 都将失效。-->
    <!--    <el-steps :active="currentStep" simple>-->
    <!--      <el-step-->
    <!--          v-for="(item, index) in stepsArr"-->
    <!--          :key="index"-->
    <!--          :title="item.title"-->
    <!--          :description="item.description"-->
    <!--          :icon="item.icon"-->
    <!--      />-->
    <!--    </el-steps>-->

    <!-- 2.当前使用的是假数据,正式组件封装可以采用Props传值的方式 -->
    <el-steps :active="values" align-center process-status="process" finish-status="success">
      <el-step
          v-for="(item, index) in stepsData"
          :key="index"
          :title="item.title"
          :description="item.date"
      />
    </el-steps>


    <!--3.采用Props传值的方式-->
    <!--    <el-steps :active="currentStep" align-center process-status="process" finish-status="success">-->
    <!--      <el-step-->
    <!--          v-for="(item, index) in stepsArr"-->
    <!--          :key="index"-->
    <!--          :title="item.title"-->
    <!--          :description="item.description"-->
    <!--      />-->
    <!--    </el-steps>-->


  </div>
</template>

<script>
export default {
  name: 'StepsComponent',
  props: {
    currentStep: {
      type: Number,
      default: 0
    },
    stepsArr: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      stepsData: [
        {
          title: '第1步',
          date: '完成时间:xxxx-xx-xx xx:xx:xx'
        },
        {
          title: '第2步',
          date: '完成时间:xxxx-xx-xx xx:xx:xx'
        },
        {
          title: '第3步',
          date: '完成时间:xxxx-xx-xx xx:xx:xx'
        },
        {
          title: '第4步',
          date: '完成时间:xxxx-xx-xx xx:xx:xx'
        },
        {
          title: '第5步',
          date: '完成时间:xxxx-xx-xx xx:xx:xx'
        },
        {
          title: '第6步',
          date: '完成时间:xxxx-xx-xx xx:xx:xx'
        },
      ],
      values: 3,
    };
  }
};
</script>


<style lang="scss" scoped>

// finish 图标
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__head.is-finish .el-step__icon {
  z-index: 1;
  color: darkgray;
  border-color: darkgray;
}

//finish title 颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__title.is-finish {
  color: darkgray;
  font-weight: 700;
}

//finish description 颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__description.is-finish {
  color: darkgray;
  font-weight: 700;
  white-space: nowrap;
}

// finish 连线  
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__head.is-finish .el-step__line {
  position: absolute;
  border-color: darkgray;
  background-color: darkgray;
}



// process 图标
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__head.is-process .el-step__icon {
  z-index: 1;
  color: #1ed2c3;
  border-color: #1ed2c3;
}

//process 文字颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__title.is-process {
  font-weight: 700;
  color: #1ed2c3;
}

//process description 颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__description.is-process {
  color: #1ed2c3;
  font-weight: 700;
  white-space: nowrap;
}

//process  连线 
/deep/ .el-steps.el-steps--horizontal.el-step.is-horizontal.is-center.el-step__head.is-process.el-step__line {
  border-color: #1ed2c3;
  background-color: #1ed2c3;
}


// wait 图标
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__head.is-wait .el-step__icon {
  z-index: 1;
  color: #f6ce06;
  border-color: #f6ce06;
}

// wait文字颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__title.is-wait {
  font-weight: 700;
  color: #f6ce06;
}

//wait description 颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__description.is-wait {
  color: #f6ce06;
  font-weight: 700;
  white-space: nowrap;
}

//wait   连线 
/deep/ .el-steps.el-steps--horizontal.el-step.is-horizontal.is-center.el-step__head.is-wait.el-step__line {
  border-color: #f6ce06;
  background-color: #f6ce06;
}




// error 图标
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__head.is-error .el-step__icon {
  z-index: 1;
  color: #ff0000;
  border-color: #ff0000;
}

// error文字颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__title.is-error {
  font-weight: 700;
  color: #ff0000;
}

//error description 颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__description.is-error {
  color: #ff0000;
  font-weight: 700;
  white-space: nowrap;
}

//error   连线  
/deep/ .el-steps.el-steps--horizontal.el-step.is-horizontal.is-center.el-step__head.is-error.el-step__line {
  border-color: #ff0000;
  background-color: #ff0000;
}


//success 图标
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__head.is-success .el-step__icon {
  z-index: 1;
  color: #5eff00;
  border-color: #5eff00;
}

// success文字颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__title.is-success {
  font-weight: 700;
  color: #5eff00;
}

//success description 颜色
/deep/ .el-steps.el-steps--horizontal .el-step.is-horizontal.is-center .el-step__description.is-success {
  color: #5eff00;
  font-weight: 700;
  white-space: nowrap;
}

//success   连线  
/deep/ .el-steps.el-steps--horizontal.el-step.is-horizontal.is-center.el-step__head.is-success.el-step__line {
  border-color: #5eff00;
  background-color: #5eff00;
}



</style>

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue2中,对于element-ui组件的二次封装,可以按照以下步骤进行: 1. 需求分析:明确需要封装element-ui组件,以及需要添加的功能和配置项。 2. 创建父组件:编写父组件的template和script代码,其中template中调用封装组件,script中定义需要传递给封装组件的props属性。 3. 创建封装组件:编写封装组件的template和script代码。在template中使用element-ui组件,并根据需要进行样式和布局的调整。在script中定义props属性,接收父组件传递的值,并监听element-ui组件的事件,触发update事件给父组件。 4. 通过临时变量传递值:由于父组件传递给封装组件的props不能直接作为封装组件的v-model属性传递给element-ui组件,所以需要在封装组件中定义一个临时变量来存储值,并将该变量与element-ui组件进行绑定。 5. 完成打通:在封装组件中监听中间件,接收到element-ui组件的update事件后,再将该事件传递给父组件。 总结来说,Vue2中对于element-ui组件的二次封装,需要创建父组件和封装组件,通过props属性传递值,并在封装组件中监听element-ui组件的事件并触发update事件给父组件。同时,需要使用临时变量来传递值给element-ui组件。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Vue3+ts+element-plus 组件的二次封装-- 页脚分页el-pagination的二次封装](https://blog.csdn.net/cs492934056/article/details/128096257)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值