search.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="search-wrapper">
  3. <view class="flex-row justify-end">
  4. <image
  5. class="search__image"
  6. referrerpolicy="no-referrer"
  7. src="/static/images/new_ui/search_icon_blod.png"
  8. />
  9. <input
  10. class="search__input"
  11. v-model="searchValue"
  12. type="text"
  13. @input="handleInput"
  14. :placeholder="placeholder"
  15. />
  16. <button class="search__btn" @click="haandleSearch">搜索</button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. props: {
  23. placeholder: {
  24. type: String,
  25. default: "请输入搜索内容",
  26. },
  27. },
  28. data() {
  29. return {
  30. searchValue: "",
  31. };
  32. },
  33. methods: {
  34. haandleSearch() {
  35. this.$emit("search", this.searchValue);
  36. },
  37. handleInput() {
  38. if (!this.searchValue) {
  39. this.$emit("search", this.searchValue);
  40. }
  41. },
  42. },
  43. };
  44. </script>
  45. <style lang="scss">
  46. .search-wrapper {
  47. background: #ffffff;
  48. height: 110rpx;
  49. display: flex;
  50. align-items: center;
  51. width: 100%;
  52. .search__image {
  53. position: absolute;
  54. width: 32rpx;
  55. height: 32rpx;
  56. left: 40rpx;
  57. top: 18rpx;
  58. }
  59. .search__input {
  60. border: 2rpx solid #000;
  61. flex: 1;
  62. height: 60rpx;
  63. margin-left: 26rpx;
  64. padding: 0 120rpx 0 55rpx;
  65. border-radius: 30rpx;
  66. margin-right: 20rpx;
  67. border: none;
  68. background: #f8f8f8;
  69. font-size: 26rpx;
  70. color: #333333;
  71. }
  72. .flex-row {
  73. display: flex;
  74. flex-direction: row;
  75. align-items: center;
  76. }
  77. .justify-end {
  78. position: relative;
  79. border-radius: 30rpx;
  80. flex: 1;
  81. }
  82. .search__btn {
  83. position: absolute;
  84. right: 20rpx;
  85. width: 108rpx;
  86. height: 60rpx;
  87. white-space: nowrap;
  88. background-color: rgba(31, 124, 255, 1);
  89. border-radius: 30rpx;
  90. text-align: center;
  91. font-size: 28rpx;
  92. line-height: 60rpx;
  93. color: rgba(255, 255, 255, 1);
  94. }
  95. }
  96. </style>