graceStar.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template name="graceStart">
  2. <view class="grace-stars">
  3. <view
  4. class="grace-stars-items" v-for="(item, index) in totalstars"
  5. :key="index"
  6. @tap="changnum"
  7. :data-val="index">
  8. <view class="grace-star-icon" :style="{'color': activecolor, 'font-size' : fontSize}" v-if="starnum > index"></view>
  9. <view class="grace-star-icon" :style="{'color': color, 'font-size' : fontSize}" v-else></view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "graceStart",
  16. props:{
  17. fontSize : {
  18. type : String,
  19. default : '50rpx'
  20. },
  21. totalstars : {
  22. type : Number,
  23. default : 5
  24. },
  25. starnum : {
  26. type : Number,
  27. default : 0
  28. },
  29. color : {
  30. type : String,
  31. default : '#E1E1E1'
  32. },
  33. activecolor :{
  34. type : String,
  35. default : '#F5C359'
  36. },
  37. cantap : {
  38. type : Boolean,
  39. default : true
  40. }
  41. },
  42. methods: {
  43. changnum : function(e){
  44. if (!this.cantap){return ;}
  45. var val = Number(e.currentTarget.dataset.val);
  46. this.$emit("starchange", Number(val + 1));
  47. }
  48. }
  49. }
  50. </script>
  51. <style scoped>
  52. .grace-stars{display:flex; flex-wrap:nowrap;}
  53. .grace-stars-items{display:inline-block; text-align:center;}
  54. .grace-star-icon{font-family:"grace-iconfont" !important; font-size:60rpx; font-style:normal;}
  55. .grace-star-icon:before{content:"\e634";}
  56. </style>