miniCard.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="miniCardComponents">
  3. <span class="title">{{ title }}</span>
  4. <h2>{{ nums }}</h2>
  5. <span class="gray">{{ precent }}:</span>
  6. <span
  7. class="precent" :class="{
  8. redP: precentData > 0,
  9. greenP: precentData < 0
  10. }"
  11. >
  12. {{ precentData || 0 }}%
  13. </span>
  14. <span v-if="precentData > 0" class="triangle up"></span>
  15. <span v-if="precentData < 0" class="triangle down"></span>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. title: {
  22. type: String,
  23. default: ''
  24. },
  25. precent: {
  26. type: String,
  27. default: ''
  28. },
  29. nums: {
  30. type: Number,
  31. default: 0
  32. },
  33. precentData: {
  34. type: Number,
  35. default: 0
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. .miniCardComponents {
  42. $red: #D04A41;
  43. $green: #427A0A;
  44. margin-right: 50px;
  45. h2 {
  46. margin: 12px 0;
  47. font-weight: bold;
  48. }
  49. .title {
  50. font-size: 16px;
  51. font-weight: 700;
  52. }
  53. .gray {
  54. color: #929292;
  55. }
  56. .precent {
  57. margin: 0 8px;
  58. }
  59. .redP {
  60. color: $red;
  61. }
  62. .greenP {
  63. color: $green;
  64. }
  65. .triangle {
  66. width: 0;
  67. height: 0;
  68. position: relative;
  69. border: 8px solid;
  70. }
  71. .up {
  72. position: relative;
  73. top: -12px;
  74. border-color: transparent transparent $red transparent;
  75. }
  76. .down {
  77. position: relative;
  78. top: 12px;
  79. border-color: $green transparent transparent transparent;
  80. }
  81. }</style>