progress.uvue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view class="progress-container">
  3. <view class="progress-bar" v-for="i in num" :key="i" :class="{
  4. 'progress-select': percentage >= i
  5. }">
  6. <view class="progress-fill"></view>
  7. <view class="progress-thumb" v-if="i !== num"></view>
  8. </view>
  9. </view>
  10. </template>
  11. <script lang="ts" setup>
  12. const props = defineProps({
  13. percentage: {
  14. type: Number,
  15. default: 2
  16. },
  17. num: {
  18. type: Number,
  19. default: 4
  20. },
  21. size: {
  22. type: String,
  23. default: '15px'
  24. }
  25. });
  26. </script>
  27. <style lang="scss" scoped>
  28. .progress-container {
  29. width: 100%;
  30. padding: 10rpx 0;
  31. @apply flex flex-row;
  32. .progress-bar {
  33. @apply flex flex-row items-center;
  34. .progress-fill {
  35. @apply rounded-full;
  36. background-color: #E4F0FF;
  37. width: v-bind(size);
  38. height: v-bind(size);
  39. }
  40. .progress-thumb {
  41. @apply rounded-full;
  42. width: v-bind(size);
  43. height: calc(v-bind(size) / 5);
  44. background-color: #E4F0FF;
  45. }
  46. }
  47. .progress-select {
  48. .progress-fill {
  49. background-color: #194DCF;
  50. }
  51. .progress-thumb {
  52. background-color: #194DCF;
  53. }
  54. }
  55. }
  56. </style>