ProgressPlus.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="progress-plus" style="width: 100%">
  3. <view class="progress-box">
  4. <view class="gray"></view>
  5. <view class="colors" :style="setColor()"></view>
  6. <view class="icon icon1"></view>
  7. <view class="icon icon2"></view>
  8. <view class="icon icon3"></view>
  9. <view class="icon icon4"></view>
  10. </view>
  11. <span style="display: inline-block;padding-left: 5px" :style="{color:color}">{{ score }}</span>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'ProgressPlus',
  17. props: {
  18. color: {
  19. type: String,
  20. default: 'green'
  21. },
  22. percent: {
  23. type: Number,
  24. default: 0
  25. },
  26. score: {
  27. type: Number,
  28. default: 0
  29. },
  30. width: {
  31. type: Number,
  32. default: 200
  33. }
  34. },
  35. methods: {
  36. setColor() {
  37. return {
  38. 'background-color': this.color,
  39. 'left': (this.percent - 100) + '%'
  40. }
  41. }
  42. }
  43. }
  44. </script>
  45. <style scoped lang="scss">
  46. .progress-plus {
  47. display: flex;
  48. align-items: center;
  49. &>span {
  50. width: 48rpx;
  51. font-size: 24rpx;
  52. }
  53. .progress-box {
  54. display: inline-block;
  55. position: relative;
  56. overflow: hidden;
  57. flex: 1;
  58. border-radius: 8rpx;
  59. &>view {
  60. width: 100%;
  61. height: 12rpx;
  62. }
  63. .gray {
  64. background-color: #E4EAF0;
  65. }
  66. .colors {
  67. /*background-color: green;*/
  68. position: absolute;
  69. top: 0;
  70. transition: left 1s;
  71. }
  72. .icon {
  73. position: absolute;
  74. width: 2px;
  75. bottom: 0;
  76. top: 0;
  77. background-color: #ffffff;
  78. &.icon1 {
  79. left: 20%;
  80. }
  81. &.icon2 {
  82. left: 40%;
  83. }
  84. &.icon3 {
  85. left: 60%;
  86. }
  87. &.icon4 {
  88. left: 80%;
  89. }
  90. }
  91. }
  92. }
  93. </style>