uni-stars.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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-dkw_jine'
  38. },
  39. iconColor:{
  40. // fontSize类型
  41. type: String,
  42. default:'#FFBD13'
  43. }
  44. },
  45. methods: {
  46. }
  47. };
  48. </script>
  49. <style scoped>
  50. .stars {
  51. height: 30upx;
  52. position: relative;
  53. float: left;
  54. }
  55. .stars-normal {
  56. width: 100%;
  57. position: absolute;
  58. left: 0;
  59. top: 0;
  60. color: #EAEAEA;
  61. }
  62. .stars-selected {
  63. position: absolute;
  64. left: 0;
  65. top: 0;
  66. z-index: 1;
  67. overflow: hidden;
  68. }
  69. </style>