TitleBar.vue 649 B

12345678910111213141516171819202122232425
  1. <script setup lang="ts">
  2. import back from '@/static/image/nav-bar/chevron-left.png'
  3. const props = defineProps<{
  4. titleName: string
  5. }>()
  6. // 获取胶囊高度
  7. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  8. function handleBack() {
  9. uni.navigateBack()
  10. }
  11. </script>
  12. <template>
  13. <view class="w-full flex items-center bg-white justify-center relative" :style="{ marginTop: `${menuButtonInfo.top}px`, height: `${menuButtonInfo.height}px` }">
  14. <image :src="back" class="absolute left-3 w-6 h-6" @tap="handleBack" />
  15. <text class="text-[18px]">
  16. {{ props.titleName }}
  17. </text>
  18. </view>
  19. </template>
  20. <style scoped>
  21. </style>