index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div
  3. class="search-bar"
  4. :style="{
  5. color: property.textColor
  6. }"
  7. >
  8. <!-- 搜索框 -->
  9. <div
  10. class="inner"
  11. :style="{
  12. height: `${property.height}px`,
  13. background: property.backgroundColor,
  14. borderRadius: `${property.borderRadius}px`
  15. }"
  16. >
  17. <div
  18. class="placeholder"
  19. :style="{
  20. justifyContent: property.placeholderPosition
  21. }"
  22. >
  23. <Icon icon="ep:search" />
  24. <span>{{ property.placeholder || '搜索商品' }}</span>
  25. </div>
  26. <div class="right">
  27. <!-- 搜索热词 -->
  28. <span v-for="(keyword, index) in property.hotKeywords" :key="index">{{ keyword }}</span>
  29. <!-- 扫一扫 -->
  30. <Icon icon="ant-design:scan-outlined" v-show="property.showScan" />
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script setup lang="ts">
  36. import { SearchProperty } from './config'
  37. /** 搜索框 */
  38. defineOptions({ name: 'SearchBar' })
  39. defineProps<{ property: SearchProperty }>()
  40. </script>
  41. <style scoped lang="scss">
  42. .search-bar {
  43. /* 搜索框 */
  44. .inner {
  45. position: relative;
  46. min-height: 28px;
  47. display: flex;
  48. align-items: center;
  49. font-size: 14px;
  50. .placeholder {
  51. display: flex;
  52. align-items: center;
  53. width: 100%;
  54. padding: 0 8px;
  55. gap: 2px;
  56. text-overflow: ellipsis;
  57. overflow: hidden;
  58. word-break: break-all;
  59. white-space: nowrap;
  60. }
  61. .right {
  62. position: absolute;
  63. right: 8px;
  64. display: flex;
  65. align-items: center;
  66. justify-content: center;
  67. gap: 8px;
  68. }
  69. }
  70. }
  71. </style>