navBar1.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="" :style="`paddingTop:${heights}px;height:${90}px`" style="width: 750rpx;background: #fff;">
  3. <view class="tab" style="top: 0;" :style="`height:${heights}px;`">
  4. </view>
  5. <view class="tab" :style="`top:${heights}px;`">
  6. <view class="" style="width: 60rpx;" @click="fanHuiFn">
  7. <uni-icons type="back" size="50rpx"></uni-icons>
  8. </view>
  9. <view class="" style="flex: 1;padding-right: 60rpx;">
  10. {{text}}
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script setup>
  16. import { ref } from 'vue'
  17. const text = ref()// tab的文字内容
  18. const heights = ref('20')//顶部高度(以胶囊底部为准)
  19. // let top = ref()//胶囊顶部距离顶部高度
  20. // const jiaoNang = ref()//获取胶囊位置信息
  21. // 获取页面传来的tab内容
  22. const props = defineProps({
  23. text: {
  24. type: String,
  25. },
  26. })
  27. text.value = props.text
  28. // // 获取顶部胶囊位置
  29. // jiaoNang.value = uni.getMenuButtonBoundingClientRect()
  30. // // 保存胶囊底部到屏幕顶部高度
  31. // heights.value = jiaoNang.value.height + jiaoNang.value.top
  32. // // 保存胶囊顶部到屏幕顶部高度
  33. // top.value = jiaoNang.value.top
  34. const getPhoneInfo = () => {
  35. const phoneInfo = uni.getSystemInfoSync(); // 获取手机系统信息
  36. // let statusBarObj = {
  37. // statusBarHeight: 20
  38. // }
  39. // 设置状态栏高度(H5顶部无状态栏小程序有状态栏需要撑起高度)
  40. console.log(phoneInfo,'高度信息啊')
  41. heights.value = phoneInfo.statusBarHeight;
  42. }
  43. getPhoneInfo()
  44. // 返回前一个页面
  45. const fanHuiFn=()=>{
  46. uni.navigateBack({
  47. delta:1
  48. })
  49. }
  50. </script>
  51. <style lang="scss">
  52. .tab {
  53. display: flex;
  54. position: fixed;
  55. top: 0;
  56. left: 0;
  57. text-align: center;
  58. overflow: hidden;
  59. background-color: #fff;
  60. color: #333;
  61. z-index: 10000;
  62. width: 750rpx;
  63. height: 90rpx;
  64. line-height: 90rpx;
  65. }
  66. </style>