HyTag.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view class="tag-item-wrapper">
  3. <view class="tag-item-content" :class="{ 'need-border': needBorder }">
  4. <image :src="minioUrl + imgUrl" :style="{ width: imgWidth, height: imgHeight }" />
  5. <view class="tag-item-text" :style="{ fontSize: fontSize }">{{ text }}</view>
  6. </view>
  7. </view>
  8. </template>
  9. <script lang="ts" setup>
  10. import { useGlobal } from '@/composables/index'
  11. const { minioUrl } = useGlobal()
  12. // props需要传入 图片宽高、文字、字号、是否需要背景边框
  13. defineProps({
  14. imgWidth: {
  15. type: String,
  16. default: '25rpx'
  17. },
  18. imgHeight: {
  19. type: String,
  20. default: '25rpx'
  21. },
  22. imgUrl: {
  23. type: String,
  24. default: '/icon_iot_canyin.png'
  25. },
  26. text: {
  27. type: String,
  28. default: '餐饮'
  29. },
  30. fontSize: {
  31. type: String,
  32. default: '22rpx'
  33. },
  34. needBorder: {
  35. type: Boolean,
  36. default: false
  37. }
  38. })
  39. </script>
  40. <style lang="scss" scoped>
  41. .tag-item-wrapper {
  42. box-sizing: border-box;
  43. margin: 0 10rpx 20rpx 0;
  44. .tag-item-content {
  45. border-radius: 4rpx;
  46. display: flex;
  47. align-items: center;
  48. width: fit-content;
  49. &.need-border {
  50. padding: 4rpx 22rpx;
  51. border: 1rpx solid#2374ff;
  52. background-color: #e6efff;
  53. }
  54. .tag-item-text {
  55. margin-left: 6rpx;
  56. line-height: 30rpx;
  57. }
  58. }
  59. }
  60. </style>