我是靠谱客的博主 满意河马,最近开发中收集的这篇文章主要介绍vue 自定义步骤条组件 自定义图片(icon),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

话不多说直接上组件代码

组件  Steps.vue

css
// css
<style lang="less" scoped>
    .step01, .step02, .step03, .step04, .step05, .step06{
        width: 20px;
        height: 20px;
        background-size: 100% 100%;
        display: inline-block;
    }
    .step01{
        background-image: url("../assets/image/Steps/Steps5.png");
    }
    .step02{
        background-image: url("../assets/image/Steps/Steps6.png");
    }
    .step03{
        background-image: url("../assets/image/Steps/Steps1.png");
    }
    .step04{
        background-image: url("../assets/image/Steps/Steps2.png");
    }
    .step05{
        background-image: url("../assets/image/Steps/Steps4.png");
    }
    .step06{
        background-image: url("../assets/image/Steps/Steps3.png");
    }
    .li_active {
        .step01{
            background-image: url("../assets/image/Steps/StepsActive5.png");
        }
        .step02{
            background-image: url("../assets/image/Steps/StepsActive6.png");
        }
        .step03{
            background-image: url("../assets/image/Steps/StepsActive1.png");
        }
        .step04{
            background-image: url("../assets/image/Steps/StepsActive2.png");
        }
        .step05{
            background-image: url("../assets/image/Steps/StepsActive4.png");
        }
        .step06{
            background-image: url("../assets/image/Steps/StepsActive3.png");
        }
    }
    .steps {
        position: relative;
    }
    /*步骤描述*/
    .steps li {
        list-style-type: none;
        font-size: 12px;
        text-align: center;
        width: 15%;
        position: relative;
        float: left;
        height: 66px;
        p{
            width: 35px;
            height: 35px;
            border: 1px solid rgba(216,216,216,1);
            border-radius: 50%;
            line-height: 43px;
            position: absolute;
            top: 0;
            left: 20px;
            background-color: #fff;
        }
        .text{
           position: absolute;
            bottom: 0;
            left: 20px; 
        }
        
        .li_active{
            border-color: rgba(41,156,245,1);
            color: rgba(41,156,245,1);
        }
    }

    /*连接线*/
    .steps li ~ li:after {
        content: "";
        width: 100%;
        height: 2px;
        border: 1px solid rgba(41,156,245,1);
        background-color: #fff;
        position: absolute;
        left: -50%;
        top: 15px;
        z-index: -1; /*放置在数字后面*/
    }

    /*将当前/完成步骤之前的数字及连接线变绿*/
    .steps li.active:before,
    .steps li.active:after {
        border: 1px solid rgba(41,156,245,1);
        background-color: #fff;
    }

    /*将当前/完成步骤之后的数字及连接线变灰*/
    .steps li.active ~ li:before,
    .steps li.active ~ li:after {
        border: 1px solid rgba(216,216,216,1);
        background-color: #fff;
    }
</style>
html
// html
<template>
    <div>
        <ul class="steps">
            <li
                v-for="(item,index) in SetData"
                :key="index"
                :class="{'active':Steps-1===index}"
            >
                <p :class="{'li_active':Steps>index}">
                    <i :class="item.icon"></i>
                </p>
                <div class="text" :class="{'li_active':Steps>index}">
                    {{item.title}}
                </div>
            </li>
        </ul>
    </div>
</template>
js
// js
<script>
export default {
    name:'Steps',
    props:{
        Steps:{
            type:Number,//数据类型
            default:1//默认值
        },//当前激活个数
    },
    data() {
        return {
            SetData : [
                {
                    title:'已立案',
                    icon:'step01'
                },
                {
                    title:'已立案',
                    icon:'step02'
                },
                {
                    title:'已立案',
                    icon:'step03'
                },
                {
                    title:'已立案',
                    icon:'step04'
                },
                {
                    title:'已立案',
                    icon:'step05'
                },
                {
                    title:'已立案',
                    icon:'step06'
                },
            ],
        }
    },
    watch: {},
    mounted() {},
    computed: {},
    components: {},
    methods: {

    },
}
</script>
实现效果

在这里插入图片描述

最后

以上就是满意河马为你收集整理的vue 自定义步骤条组件 自定义图片(icon)的全部内容,希望文章能够帮你解决vue 自定义步骤条组件 自定义图片(icon)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(33)

评论列表共有 0 条评论

立即
投稿
返回
顶部