Rate.vue 564 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <div class="rate">
  3. <span>☆☆☆☆☆</span>
  4. <div class="hollow" :style="style">
  5. ★★★★★
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. value: {type: [Number, String], default: '0'}
  13. },
  14. computed: {
  15. style () {
  16. return `width:${this.value / 2}em`
  17. }
  18. }
  19. }
  20. </script>
  21. <style lang="scss" scoped>
  22. .rate {
  23. position: relative;
  24. display: inline-block;
  25. .hollow {
  26. position: absolute;
  27. display: inline-block;
  28. top: 0;
  29. left: 0;
  30. width: 0;
  31. overflow: hidden;
  32. }
  33. }
  34. </style>