vue组件实现进度条效果
更新时间:2018年06月06日 11:14:42 作者:wl_
这篇文章主要为大家详细介绍了vue组件实现进度条效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了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>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
相关文章
vue2和elementUI 实现落日余晖登录页和滑块校验功能
这篇文章主要介绍了vue2和elementUI打造落日余晖登录页和滑块校验,本文通过实例代码给大家介绍的非常详细,需要的朋友可以参考下2023-06-06
vue模块导入报错问题Module not found: Error:[CaseSensi
这篇文章主要介绍了vue模块导入报错问题Module not found: Error:[CaseSensitivePathsPlugin],具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-06-06
Vue3中关于getCurrentInstance的大坑及解决
这篇文章主要介绍了Vue3中关于getCurrentInstance的大坑及解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-04-04
详解vuex中的this.$store.dispatch方法
这篇文章主要介绍了vuex中的this.$store.dispatch方法,必须要用commit(‘SET_TOKEN’, tokenV)调用mutations里的方法,才能在store存储成功,需要的朋友可以参考下2022-11-11


最新评论