badge.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="tui-badge-class" :class="[dot?'tui-badge-dot':'tui-badge','tui-'+type, size?'tui-badge-small':'']" v-if="visible">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. name: "tuiBadge",
  9. props: {
  10. //primary,warning,green,danger,white,black,gray
  11. type: {
  12. type: String,
  13. default: 'primary'
  14. },
  15. // '', small
  16. size: {
  17. type: String,
  18. default: ''
  19. },
  20. //是否是圆点
  21. dot: {
  22. type: Boolean,
  23. default: false
  24. },
  25. //是否可见
  26. visible: {
  27. type: Boolean,
  28. default: true
  29. }
  30. }
  31. }
  32. </script>
  33. <style>
  34. /* color start*/
  35. .tui-primary {
  36. background: #C74547;
  37. color: #fff;
  38. }
  39. .tui-danger {
  40. background: #ed3f14;
  41. color: #fff;
  42. }
  43. .tui-red {
  44. background: #ff201f;
  45. color: #fff;
  46. }
  47. .tui-warning {
  48. background: #ff7900;
  49. color: #fff;
  50. }
  51. .tui-green {
  52. background: #19be6b;
  53. color: #fff;
  54. }
  55. .tui-white {
  56. background: #fff;
  57. color: #333;
  58. }
  59. .tui-black {
  60. background: #000;
  61. color: #fff;
  62. }
  63. .tui-gray {
  64. background: #ededed !important;
  65. color: #999 !important;
  66. }
  67. /* color end*/
  68. /* badge start*/
  69. .tui-badge-dot {
  70. height: 8px;
  71. width: 8px;
  72. border-radius: 4px;
  73. line-height: 1;
  74. }
  75. .tui-badge {
  76. font-size: 12px;
  77. line-height: 1;
  78. padding: 3px 6px;
  79. border-radius: 50px;
  80. }
  81. .tui-badge-small {
  82. transform: scale(0.8);
  83. transform-origin: center center;
  84. }
  85. /* badge end*/
  86. </style>