gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<script setup lang="ts">
import type { SearchProperty } from './config';
 
import { IconifyIcon } from '..\..\..\..\..\..\..\..\packages\icons\src';
 
/** 搜索框 */
defineOptions({ name: 'SearchBar' });
 
defineProps<{ property: SearchProperty }>();
</script>
 
<template>
  <div
    :style="{
      color: property.textColor,
    }"
  >
    <!-- 搜索框 -->
    <div
      class="relative flex min-h-7 items-center text-sm"
      :style="{
        height: `${property.height}px`,
        background: property.backgroundColor,
        borderRadius: `${property.borderRadius}px`,
      }"
    >
      <div
        class="flex w-full items-center gap-0.5 overflow-hidden text-ellipsis whitespace-nowrap break-all px-2"
        :style="{
          justifyContent: property.placeholderPosition,
        }"
      >
        <IconifyIcon icon="lucide:search" />
        <span>{{ property.placeholder || '搜索商品' }}</span>
      </div>
      <div class="absolute right-2 flex items-center justify-center gap-2">
        <!-- 搜索热词 -->
        <span v-for="(keyword, index) in property.hotKeywords" :key="index">
          {{ keyword }}
        </span>
        <!-- 扫一扫 -->
        <IconifyIcon icon="lucide:scan-barcode" v-show="property.showScan" />
      </div>
    </div>
  </div>
</template>