headerInput.vue 911 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <view class="container">
  3. <uni-icons type="search" size="24" color="#808080"></uni-icons>
  4. <input class="input" type="text" placeholder="请输入关键词" placeholder-style="color:#CCCCCC;font-size:28rpx" @input="handleInput" />
  5. </view>
  6. </template>
  7. <script setup>
  8. import { ref } from 'vue'
  9. const $emit = defineEmits(['changeInputValue'])
  10. const timer = ref(null)
  11. const handleInput = (e) => {
  12. if (timer.value) {
  13. clearTimeout(timer.value)
  14. }
  15. timer.value = setTimeout(() => {
  16. $emit('changeInputValue', e.detail.value)
  17. }, 500)
  18. }
  19. </script>
  20. <style lang="scss" scoped>
  21. .container {
  22. position: relative;
  23. display: flex;
  24. align-items: center;
  25. box-sizing: border-box;
  26. padding: 0 40rpx;
  27. margin-top: 30rpx;
  28. width: 710rpx;
  29. height: 100rpx;
  30. border-radius: 80rpx;
  31. border: 1rpx solid #ccc;
  32. background-color: #fff;
  33. .input {
  34. margin-left: 16rpx;
  35. width: 100%;
  36. height: 100%;
  37. }
  38. }
  39. </style>