组件库 | 步骤条

简介: 在写移动端步骤条的时候,发现第三方的步骤条满足不了需求,于是手写了一个

image.png

在写移动端步骤条的时候,发现第三方的步骤条满足不了需求,于是手写了一个。代码如下:(字数不够来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑来凑)“


<!-- 步骤条组件 -->
<template>
<div
     id="steps"
     :style="`display:flex;flex-direction:${stepStyle.flexDirection};`"
     >
  <div
       v-for="(item, index) in stepList"
       :key="index"
       class="steps"
       :style="`display:flex;flex-direction:${stepStyle.stepsFlexDirection};`"
       >
    <p
       class="icon"
       :style="`background-color: ${
               active >= index ? stepStyle.stepsActiveColor : '#CCCCCC'
               };`"
       >
      {
  
  { index + 1 }}
  </p>
    <p
       class="name"
       :style="`color:${
               active >= index ? stepStyle.stepsActiveColor : '#CCCCCC'
               }`"
       >
      {
  
  { item }}
  </p>
  </div>
  </div>
</template>

<script lang="ts">
  import { defineComponent, reactive, toRefs } from "vue";
  export default defineComponent({
    name: "steps",
    components: {},
    props: {
      stepStyle: {
        type: Object,
        default() {
          return {
            flexDirection: "row",
            stepsFlexDirection: "column",
            stepsActiveColor: "#0077dd",
          };
        },
      },
      stepList: {
        type: Array,
        default() {
          return [];
        },
      },
      active: {
        type: Number,
        default: 0,
      },
    },
    setup(props) {
      console.log("props", props.stepStyle);
      const data = reactive({});
      return {
        ...toRefs(data),
      };
    },
  });
</script>

<style lang="scss" scoped>
  #steps {
    .steps {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      // height: 70px;
      .icon {
        height: 30px;
        width: 30px;
        border-radius: 50%;
        color: #ffffff;
        display: flex;
        justify-content: center;
        align-items: center;
      }

      .name {
        width: 56px;
        height: 20px;
        font-family: PingFangSC-Medium;
        font-weight: 500;
        font-size: 14px;
        text-align: center;
        padding-top: 4px;
      }
    }

    .steps:not(:last-child)::after {
      content: "";
      width: calc(100% - 35px);
      height: 1px;
      border-bottom: 2px solid #cccccc;
      display: inline-block;
      margin-left: 100%;
      margin-top: -40px;
    }
    .steps:last-child::after {
      content: "";
      display: inline-block;
      margin-left: 100%;
      margin-top: -40px;
    }
  }
</style>
相关文章
|
3月前
|
前端开发
组件库的使用
组件库的使用
23 1
|
3月前
为什么要使用组件库?
为什么要使用组件库?
68 0
|
4天前
|
缓存 前端开发
ProFlow 流程编辑器框架问题之创建一个自定义节点如何解决
ProFlow 流程编辑器框架问题之创建一个自定义节点如何解决
13 1
|
3月前
|
算法 关系型数据库 编译器
[项目配置] 配置Qt函数库和ui界面库的封装并调用的项目(一)
[项目配置] 配置Qt函数库和ui界面库的封装并调用的项目
129 0
|
3月前
|
C++
[项目配置] 配置Qt函数库和ui界面库的封装并调用的项目(二)
[项目配置] 配置Qt函数库和ui界面库的封装并调用的项目
79 0
|
9月前
|
前端开发 程序员
前端反卷计划-组件库-02-storybook
前端反卷计划-组件库-02-storybook
前端反卷计划-组件库-02-storybook
|
前端开发
React组件导入的两种方式(动态导入组件的实现)
React组件导入的两种方式(动态导入组件的实现)
220 0
|
开发工具 git
从0搭建Vue3组件库(八):使用 release-it 实现自动管理发布组件库
从0搭建Vue3组件库(八):使用 release-it 实现自动管理发布组件库
160 0
|
JavaScript 开发者
Vite 在运行过程中是如何发现新增依赖的?
Vite 在运行过程中是如何发现新增依赖的?
201 0
|
前端开发 JavaScript 编译器
搭建Vue3组件库:第十三章 实现组件库按需引入功能
本章介绍组件库如何实现按需引入。
1540 0
搭建Vue3组件库:第十三章 实现组件库按需引入功能