uni-tag.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view
  3. v-if="text"
  4. :class="[
  5. disabled === true || disabled === 'true' ? 'uni-tag--disabled' : '',
  6. circle === true || circle === 'true' ? 'uni-tag--circle' : '',
  7. mark === true || mark === 'true' ? 'uni-tag--mark' : '',
  8. 'uni-tag--' + size,
  9. inverted ? 'uni-tag--inverted' + ' text-'+themeColor.name : 'bg-'+themeColor.name
  10. ]"
  11. class="uni-tag"
  12. @tap="onClick()"
  13. >
  14. <!-- 'uni-tag&#45;&#45;' + type-->
  15. {{ text }}
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'UniTag',
  21. props: {
  22. type: {
  23. // 标签类型default、primary、success、warning、danger、royal
  24. type: String,
  25. default: 'default'
  26. },
  27. size: {
  28. // 标签大小 normal, small
  29. type: String,
  30. default: 'normal'
  31. },
  32. // 标签内容
  33. text: {
  34. type: String,
  35. default: ''
  36. },
  37. disabled: {
  38. // 是否为禁用状态
  39. type: [String, Boolean],
  40. defalut: false
  41. },
  42. inverted: {
  43. // 是否为空心
  44. type: [String, Boolean],
  45. defalut: false
  46. },
  47. circle: {
  48. // 是否为圆角样式
  49. type: [String, Boolean],
  50. defalut: false
  51. },
  52. mark: {
  53. // 是否为标记样式
  54. type: [String, Boolean],
  55. defalut: false
  56. }
  57. },
  58. methods: {
  59. onClick() {
  60. if (this.disabled === true || this.disabled === 'true') {
  61. return;
  62. }
  63. this.$emit('click');
  64. }
  65. }
  66. };
  67. </script>
  68. <style lang="scss">
  69. .uni-tag {
  70. box-sizing: border-box;
  71. padding: 0 32upx;
  72. height: 60upx;
  73. line-height: calc(60upx - 2px);
  74. font-size: 28upx;
  75. display: inline-flex;
  76. align-items: center;
  77. /*color: #333;*/
  78. border-radius: 6upx;
  79. /*background-color: #f8f8f8;*/
  80. border: 1px solid #f8f8f8;
  81. }
  82. .uni-tag--circle {
  83. border-radius: 30upx;
  84. }
  85. .uni-tag--mark {
  86. border-radius: 0 30upx 30upx 0;
  87. }
  88. .uni-tag--disabled {
  89. opacity: 0.5;
  90. }
  91. .uni-tag--small {
  92. height: 40upx;
  93. padding: 0 16upx;
  94. line-height: calc(40upx - 2px);
  95. font-size: 24upx;
  96. }
  97. .uni-tag--primary {
  98. color: #fff;
  99. background-color: #007aff;
  100. border: 1px solid #007aff;
  101. }
  102. .uni-tag--primary.uni-tag--inverted {
  103. border: 1px solid;
  104. }
  105. .uni-tag--success {
  106. color: #fff;
  107. background-color: #4cd964;
  108. border: 1px solid #4cd964;
  109. }
  110. .uni-tag--success.uni-tag--inverted {
  111. border: 1px solid;
  112. }
  113. .uni-tag--warning {
  114. color: #fff;
  115. background-color: #f0ad4e;
  116. border: 1px solid #f0ad4e;
  117. }
  118. .uni-tag--warning.uni-tag--inverted {
  119. border: 1px solid;
  120. }
  121. .uni-tag--error {
  122. color: #fff;
  123. border: 1px solid;
  124. }
  125. .uni-tag--error.uni-tag--inverted {
  126. color: #dd524d;
  127. background-color: #fff;
  128. border: 1px solid #dd524d;
  129. }
  130. .uni-tag--inverted {
  131. border: 1px solid;
  132. }
  133. .uni-tag--base.uni-tag--inverted {
  134. border: 1px solid;
  135. }
  136. .uni-tag--base {
  137. color: #333;
  138. background-color: #fff;
  139. border: 1px solid #f8f8f8;
  140. }
  141. </style>