search.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <script lang="ts" setup>
  2. import { ref } from 'vue'
  3. import { StaticUrl } from '@/config'
  4. // 如果需要从外部传入动态文本,可以使用 props
  5. defineProps<{
  6. initialMapModeText?: string
  7. }>()
  8. // 如果需要从外部传入点击事件处理方法,也可以定义 emit
  9. defineEmits<{
  10. (e: 'mapModeClick'): void
  11. }>()
  12. // 定义动态文本
  13. const mapModeText = ref('地图模式')
  14. // 定义点击事件处理方法
  15. function onMapModeClick() {
  16. // 在这里添加点击逻辑
  17. console.log('地图模式被点击')
  18. // 示例:切换显示文本
  19. // mapModeText.value = mapModeText.value === '地图模式' ? '列表模式' : '地图模式'
  20. }
  21. </script>
  22. <template>
  23. <view class="flex items-center justify-between">
  24. <view class="search-box flex items-center">
  25. <view class="mr-16rpx flex items-center">
  26. <image :src="`${StaticUrl}/location-black.png`" class="h33.8rpx min-w28.97rpx w28.97rpx" />
  27. <text class="ml-1">
  28. 贵阳
  29. </text>
  30. </view>
  31. <view class="h-36rpx border-2rpx border-#AAAAAA border-solid" />
  32. <view class="ml-16rpx text-#AAAAAA">
  33. 请输入目的地/电站名
  34. </view>
  35. </view>
  36. <view class="search-box flex items-center gap-20rpx" @click="onMapModeClick">
  37. <image :src="`${StaticUrl}/charge-map.png`" class="h-40rpx w-40rpx" mode="" />
  38. <text>
  39. {{ mapModeText }}
  40. </text>
  41. </view>
  42. </view>
  43. </template>
  44. <style scoped lang="scss">
  45. .search-box{
  46. background: rgba(255, 255, 255, 0.7);
  47. border-radius: 16rpx;
  48. padding: 10rpx 20rpx;
  49. }
  50. </style>