Vue组件实现进度条效果

一、效果图

8744FE2D-048D-DDDC-A05D-07F2BD4E8551.png

二、代码

progress-bar.vue

<template>
    <div class="vue-progress-bar default-theme">
        <div class="vue-progress-bar__tip">
            <span class="vue-progress-bar__tiplabel">{{label}}</span>
            <span class="vue-progress-bar__tiptext">{{text}}</span>
        </div>
        <div class="vue-progress-bar__outer">
            <div class="vue-progress-bar__inner" :style="barStyle"></div>
        </div>
    </div>
</template>

<script>export default {
        props:{
            label:String,
            text:String,
            height:{
                type: Number,
                default: ,
                required: true,
                validator: val => val >= 
            },
            color: {
                type: String,
                default: ''
            },
            percentage:{
                type: Number,
                default: ,
                required: true,
                validator: val => val >=  && val <= 100
            }
        },
        computed:{
            barStyle() {
                const style = {};
                style.width = this.percentage + '%';
                style.height = this.height + 'px';
                style.backgroundColor = this.color;
                return style;
            }
        }
    }</script>

<style lang="scss" scoped>.vue-progress-bar.default-theme{
        .vue-progress-bar__outer { background: #eee;
        }
    }

    .vue-progress-bar {
        .vue-progress-bar__tiptext { float: right;
        }
    }</style>
收藏 (0)
评论列表
正在载入评论列表...
我是有底线的