index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <view class="navbar-box" :style="{'height': navbarHeight + 'px', 'paddingTop': statusBarHeight + 'px'}">
  3. <image src="https://minio.citupro.com/dev/menduner/poster.png" class="navbar-box-logo" :style="{'height': (navbarHeight - 10) + 'px'}"></image>
  4. <!-- <view class="navbar-box-title">{{ title }}</view> -->
  5. </view>
  6. </template>
  7. <script setup>
  8. import { ref } from 'vue'
  9. import { onLoad } from '@dcloudio/uni-app'
  10. defineProps({
  11. title: {
  12. type: String,
  13. default: '门墩儿'
  14. }
  15. })
  16. const navbarHeight = ref(0)
  17. const statusBarHeight = ref(0)
  18. onLoad(() => {
  19. const systemInfo = uni.getSystemInfoSync()
  20. statusBarHeight.value = systemInfo.statusBarHeight
  21. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  22. navbarHeight.value = menuButtonInfo.height + ((menuButtonInfo.top - statusBarHeight.value) * 2) + 10
  23. })
  24. </script>
  25. <style scoped lang="scss">
  26. .navbar-box {
  27. width: 100%;
  28. position: relative;
  29. background: linear-gradient(90deg, #66BB6A 0, #64FFDA 100%);
  30. &-logo {
  31. position: absolute;
  32. left: 50%;
  33. transform: translateX(-50%);
  34. width: 100px;
  35. }
  36. // &-title {
  37. // position: absolute;
  38. // top: 50%;
  39. // left: 50%;
  40. // transform: translate(-30%, 0);
  41. // color: #fff;
  42. // }
  43. }
  44. </style>