SearchBox.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="search-content"
  3. :style="{height:height+'rpx',paddingTop:paddingTop+'rpx',position:isFixed ? 'fixed':'static'}">
  4. <view class="search-input">
  5. <text class="iconfont search-icon">&#xe618;</text>
  6. <input class="input-box" placeholder-class="input-placeholder" placeholder="搜索" @confirm="$emit('search', $event.detail.value)"/>
  7. </view>
  8. </view>
  9. <view v-if="isFixed" class="search-placeholder" :style="{height:130+'rpx'}" />
  10. </template>
  11. <script lang="ts" setup>
  12. defineProps({
  13. height: {
  14. type: Number,
  15. default: 130
  16. },
  17. paddingTop: {
  18. type: Number,
  19. default: 20
  20. },
  21. isFixed: {
  22. type: Boolean,
  23. default: true
  24. }
  25. })
  26. </script>
  27. <style lang="scss" scoped>
  28. .search-content {
  29. background-color: inherit;
  30. position: fixed;
  31. left: 0;
  32. right: 0;
  33. z-index: 1;
  34. box-sizing: border-box;
  35. padding: 0 23rpx;
  36. .search-input {
  37. width: 100%;
  38. display: flex;
  39. align-items: center;
  40. height: 80rpx;
  41. background-color: #fff;
  42. border-radius: 40rpx;
  43. padding: 0 30rpx;
  44. box-sizing: border-box;
  45. .search-icon {
  46. color: #666666;
  47. font-size: 40rpx;
  48. flex-shrink: 0;
  49. // font-weight: 600;
  50. }
  51. .input-box {
  52. flex: 1;
  53. height: 100%;
  54. padding-left: 25rpx;
  55. font-size: 28rpx;
  56. font-family: PingFang SC, PingFang SC-Regular;
  57. font-weight: 400;
  58. color: #666666;
  59. }
  60. .input-placeholder {
  61. color: #b3b3b3;
  62. }
  63. }
  64. }
  65. </style>