uni-stars.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="stars" :style="{ width:widthInfo + 'rpx' }">
  3. <view class="stars-normal">
  4. <view class="box" :style="{ width:widthInfo + 'rpx' }">
  5. <block v-for="i_ in 5" :key="i_"><text class="iconfont" :class="iconClass" :style="{fontSize:fontSize+'rpx'}"></text></block>
  6. </view>
  7. </view>
  8. <view class="stars-selected" :style="{ width: (stars / 5) * 100 + '%',color:iconColor}">
  9. <view class="box" :style="{ width:widthInfo + 'rpx' }">
  10. <block v-for="j_ in 5" :key="j_"><text class="iconfont" :class="iconClass" :style="{fontSize:fontSize+'rpx'}"></text></block>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: "Unistars",
  18. props: {
  19. stars: {
  20. // Unistars类型
  21. type: Number,
  22. default: 0
  23. },
  24. fontSize:{
  25. // fontSize类型
  26. type: Number,
  27. default: 30
  28. },
  29. widthInfo:{
  30. // fontSize类型
  31. type: Number,
  32. default: 146
  33. },
  34. iconClass:{
  35. // fontSize类型
  36. type: String,
  37. default:'icon-qian1'
  38. },
  39. iconColor:{
  40. // fontSize类型
  41. type: String,
  42. default:'#FFBD13'
  43. }
  44. },
  45. created() {
  46. },
  47. methods: {
  48. }
  49. };
  50. </script>
  51. <style scoped>
  52. .stars {
  53. height: 30upx;
  54. position: relative;
  55. float: left;
  56. }
  57. .stars-normal {
  58. width: 100%;
  59. position: absolute;
  60. left: 0;
  61. top: 0;
  62. color: #EAEAEA;
  63. }
  64. .stars-selected {
  65. position: absolute;
  66. left: 0;
  67. top: 0;
  68. z-index: 1;
  69. overflow: hidden;
  70. }
  71. </style>