vue组件实现进度条效果

vue组件实现进度条效果

二、代码

progress-bar.vue

<template> <div> <div> <span>{{label}}</span> <span>{{text}}</span> </div> <div> <div :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>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9d9e0aeff1697ee24e09eadc77c92d17.html