You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.3 KiB

1 month ago
  1. <template>
  2. <view class="searchBg">
  3. <view class="flex">
  4. <view class="searchIcon">
  5. <image src="@/static/images/searchIcon.png" mode=""></image>
  6. </view>
  7. <view class="inputBox">
  8. <u-search :placeholder="placeholder" searchIcon=" " v-model="keyword" :color="'#333'"
  9. :disabled="disable" placeholderColor="#9C9C9C" :bgColor="'transparent'"
  10. @change="$u.debounce(searchFn, 1500)" :showAction="false" @search="$u.debounce(searchFn, 500)"
  11. @clear="clearSearchFn"></u-search>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. defineProps({
  18. placeholder: {
  19. type: String,
  20. default: ''
  21. },
  22. disable: {
  23. type: Boolean,
  24. default: false
  25. }
  26. })
  27. import {ref} from 'vue'
  28. let emit = defineEmits()
  29. let keyword = ref('')
  30. function searchFn() {
  31. emit('searchFn', keyword.value)
  32. }
  33. function clearSearchFn() {
  34. keyword.value = ''
  35. }
  36. </script>
  37. <style lang="scss" scoped>
  38. image {
  39. display: block;
  40. width: 100%;
  41. height: 100%;
  42. }
  43. .searchBg {
  44. background: #EFEFEF;
  45. width: 100%;
  46. height: 72rpx;
  47. border-radius: 10rpx;
  48. line-height: 72rpx;
  49. .flex {
  50. height: 100%;
  51. padding: 0 28rpx;
  52. .searchIcon {
  53. width: 32rpx;
  54. height: 32rpx;
  55. }
  56. .inputBox {
  57. flex: 1;
  58. color: #333;
  59. font-size: 28rpx;
  60. margin-left: -16rpx;
  61. }
  62. }
  63. }
  64. </style>