cu-progress.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="cu-progress" :style="'height: ' + progressHeight + '; width: ' + progressWidth + ';background-color: ' + progressColor">
  3. <view class="cu-progress-bar" :style="'background-color: ' + progressBarColor + ';left: ' + barLeft + 'rpx; width:' + barWidth + 'rpx'">
  4. </view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. currentSwiper: 0,
  12. // 剩余滑行距离
  13. offset: 0,
  14. barLeft: 0
  15. };
  16. },
  17. components: {},
  18. props: {
  19. progressBarColor: {
  20. type: String,
  21. default: '#01B55B'
  22. },
  23. progressWidth: {
  24. type: Number,
  25. default: 90
  26. },
  27. progressHeight: {
  28. type: Number,
  29. default: 6
  30. },
  31. progressColor: {
  32. type: String,
  33. default: '#E5E5E5'
  34. },
  35. left: {
  36. type: Number,
  37. default: 0
  38. },
  39. barWidth: {
  40. type: Number,
  41. default: 30
  42. }
  43. },
  44. watch: {
  45. 'left': function (value) {
  46. this.barLeft = value / 100 * this.offset
  47. }
  48. },
  49. beforeMount: function () {
  50. this.offset = this.progressWidth - this.barWidth
  51. },
  52. destroyed: function () {},
  53. methods: {
  54. }
  55. };
  56. </script>
  57. <style>
  58. .cu-progress {
  59. background-color: #E5E5E5;
  60. height: 6rpx;
  61. width: 90rpx;
  62. position: relative;
  63. }
  64. .cu-progress .cu-progress-bar {
  65. height: 100%;
  66. width: 30rpx;
  67. position: absolute;
  68. left: 0;
  69. }
  70. </style>