navbar.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view>
  3. <view class="wx-head-mod" :style="{height:navHeight+'rpx'}">
  4. <view class="wx-head-mod-nav" :style="{height:navigationBarHeight+'rpx',top:statusBarHeight+'rpx'}">
  5. <view class="wx-head-mod-nav-content"
  6. :style="{height:customHeight+'rpx',justifyContent:'left'}">
  7. <!-- 文本区 -->
  8. <view class="wx-head-mod-nav-content-mian"
  9. :style="{lineHeight:customHeight + 'rpx'}">
  10. {{title}}
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import {systemInfo} from '@/component/system-info.js'
  19. export default {
  20. name: "HeadView",
  21. props: {
  22. // 文本区内容
  23. title:'',
  24. },
  25. data() {
  26. return {
  27. statusBarHeight: 0, //状态栏高度
  28. navHeight: 0, //头部导航栏总体高度
  29. navigationBarHeight:0, //导航栏高度
  30. customHeight: 0, //胶囊高度
  31. scaleFactor: 0, //比例系数
  32. menubarLeft:0, //胶囊定位的左边left
  33. windowWidth: 0
  34. };
  35. },
  36. methods: {
  37. },
  38. created() {
  39. /* 获取设备信息 */
  40. const SystemInfomations = systemInfo()
  41. /* 通用平台 */
  42. this.statusBarHeight = SystemInfomations.statusBarHeight //状态栏高度
  43. this.scaleFactor = SystemInfomations.scaleFactor //比例系数
  44. this.windowWidth = SystemInfomations.windowWidth //当前设备的屏幕宽度
  45. /* 微信小程序平台 */
  46. // #ifdef MP-WEIXIN
  47. this.navHeight = SystemInfomations.navHeight + SystemInfomations.statusBarHeight //头部导航栏总高度
  48. this.navigationBarHeight = SystemInfomations.navHeight //头部导航栏高度
  49. this.customHeight = SystemInfomations.menuButtonHeight //胶囊高度
  50. this.menubarLeft = SystemInfomations.menuButtonLeft //胶囊左边界距离左上角的距离
  51. // #endif
  52. }
  53. }
  54. </script>
  55. <style>
  56. .wx-head-mod {
  57. box-sizing: border-box;
  58. width: 100%;
  59. position: fixed;
  60. top: 0;
  61. left: 0;
  62. //background: #0183FA;
  63. /* background: linear-gradient(-35deg, #613A19 0%, #6F4E2B 100%); */
  64. }
  65. .wx-head-mod-nav {
  66. box-sizing: border-box;
  67. width: 100%;
  68. position: absolute;
  69. left: 0;
  70. display: flex;
  71. justify-content: center;
  72. align-items: center;
  73. }
  74. .wx-head-mod-nav-content {
  75. box-sizing: border-box;
  76. width: 100%;
  77. display: flex;
  78. justify-content: left;
  79. align-items: center;
  80. position: relative;
  81. padding-left: 30rpx;
  82. box-sizing: border-box;
  83. }
  84. /* 文本区 */
  85. .wx-head-mod-nav-content-mian {
  86. box-sizing: border-box;
  87. height: 100%;
  88. text-align: center;
  89. white-space: nowrap;
  90. text-overflow: ellipsis;
  91. overflow: hidden;
  92. color:#fff;
  93. font-size:36rpx;
  94. }
  95. /* 返回按钮 */
  96. .wx-head-mod-nav-content-back {
  97. box-sizing: border-box;
  98. width: 60rpx;
  99. height: 100%;
  100. /* background-color: aqua; */
  101. position: absolute;
  102. top: 0;
  103. left: 32rpx;
  104. display: flex;
  105. align-items: center;
  106. justify-content: left;
  107. }
  108. .wx-head-mod-nav-content-back-img {
  109. box-sizing: border-box;
  110. }
  111. </style>