本文实例为大家分享了vue实现进度条效果的具体代码,供大家参考,具体内容如下
一、效果图
二、代码
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: 0, required: true, validator: val => val >= 0 }, color: { type: String, default: '' }, percentage:{ type: Number, default: 0, required: true, validator: val => val >= 0 && 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>
Copyright © 2019- azee.cn 版权所有 赣ICP备2024042794号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务