common-search.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view class="common_search">
  3. <uni-icons type="search" size="30" color="#999999"></uni-icons>
  4. <input v-model="searchValue" class="input" type="text" :placeholder="placeholder" />
  5. <view class="btn" @click="handleSearch">搜索</view>
  6. </view>
  7. </template>
  8. <script setup>
  9. import { ref } from 'vue'
  10. defineProps(['placeholder'])
  11. const $emit = defineEmits(['change'])
  12. // 搜索框绑定值
  13. const searchValue = ref('')
  14. // 点击搜索按钮回调
  15. const handleSearch = () => {
  16. // console.log(searchValue.value)
  17. // if (searchValue.value.trim()) {
  18. // $emit('change', searchValue.value.trim())
  19. // }
  20. $emit('change', searchValue.value.trim())
  21. }
  22. </script>
  23. <style lang="scss" scoped>
  24. .common_search {
  25. display: flex;
  26. align-items: center;
  27. padding: 0 5rpx 0 35rpx;
  28. width: 714rpx;
  29. height: 80rpx;
  30. border-radius: 145rpx;
  31. border: 2rpx solid #e5e5e5;
  32. background-color: #f5f5f5;
  33. .input {
  34. flex: 1;
  35. padding: 20rpx;
  36. font-size: 28rpx;
  37. }
  38. .btn {
  39. display: flex;
  40. justify-content: center;
  41. align-items: center;
  42. margin-left: auto;
  43. width: 141rpx;
  44. height: 69rpx;
  45. font-size: 28rpx;
  46. color: #fff;
  47. border-radius: 68rpx;
  48. background-color: #007aff;
  49. }
  50. }
  51. </style>