navBar3.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view class="tab" :style="`height:${heights+6}px;`">
  3. <view class="neirong" style="width: 100%;"
  4. :style="`height:${heights-top}px;font-size:${(heights-top)*0.6}px;margin-top:${top}px;`">
  5. <!-- <image @click="fanHuiFn()" class="img" src="@/static/icon_fanhui@2x.png" mode=""></image> -->
  6. {{text}}
  7. </view>
  8. </view>
  9. </template>
  10. <script lang="ts" setup>
  11. import { ref } from 'vue'
  12. let text = ref()// tab的文字内容
  13. let heights = ref()//顶部高度(以胶囊底部为准)
  14. let top = ref()//胶囊顶部距离顶部高度
  15. const jiaoNang = ref()//获取胶囊位置信息
  16. // 获取页面传来的tab内容
  17. const props = defineProps({
  18. text: {
  19. type: String,
  20. },
  21. })
  22. // 返回前一个页面
  23. const fanHuiFn=()=>{
  24. uni.navigateBack({
  25. delta:1
  26. })
  27. }
  28. text.value = props.text
  29. // 获取顶部胶囊位置
  30. jiaoNang.value = uni.getMenuButtonBoundingClientRect()
  31. // 保存胶囊底部到屏幕顶部高度
  32. heights.value = jiaoNang.value.height + jiaoNang.value.top
  33. // 保存胶囊顶部到屏幕顶部高度
  34. top.value = jiaoNang.value.top
  35. </script>
  36. <style lang="scss">
  37. .tab {
  38. text-align: center;
  39. overflow: hidden;
  40. // background-color: #fff;
  41. color: #333;
  42. .neirong{
  43. position: relative;
  44. .img{
  45. position: absolute;
  46. top: 10rpx;
  47. left: 20rpx;
  48. width: 26rpx;
  49. height: 32rpx;
  50. }
  51. }
  52. }
  53. </style>