pingfen.vue 842 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <span class="component-pingfen">
  3. <i v-for="(_,index) in myData"
  4. :class="{'active': +myValue >= index,
  5. 'not-active': +myValue < index}">
  6. </i>
  7. </span>
  8. </template>
  9. <script>
  10. export default {
  11. name: "pingfen",
  12. props: {
  13. total: {
  14. type: Number | String,
  15. default: 10
  16. },
  17. value: {
  18. type: Number | String,
  19. default: 0
  20. }
  21. },
  22. computed: {
  23. myData() {
  24. return Array(this.myTotal).fill('');
  25. },
  26. myTotal() {
  27. return +this.total
  28. },
  29. myValue() {
  30. return +this.value-1
  31. },
  32. },
  33. }
  34. </script>
  35. <style lang="scss" scoped>
  36. .component-pingfen {
  37. display: flex;
  38. justify-content: flex-start;
  39. i {
  40. margin: 0 10px ;
  41. width:3px;
  42. &.active {
  43. background: red;
  44. }
  45. &.not-active {
  46. background: #2c98f2;
  47. }
  48. }
  49. }
  50. </style>