App.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <script>
  2. export default {
  3. globalData: {
  4. statusBarHeight: 0, // 状态导航栏高度
  5. navHeight: 0, // 总体高度
  6. navigationBarHeight: 0, // 导航栏高度(标题栏高度)
  7. },
  8. onLaunch: function() {
  9. console.log('App Launch')
  10. // console.log('App Launch')
  11. // 状态栏高度
  12. this.globalData.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
  13. // #ifdef MP-WEIXIN
  14. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  15. const custom = wx.getMenuButtonBoundingClientRect()
  16. // console.log(custom)
  17. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  18. this.globalData.navigationBarHeight = custom.height + (custom.top - this.globalData.statusBarHeight) * 2
  19. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  20. // 总体高度 = 状态栏高度 + 导航栏高度
  21. this.globalData.navHeight = this.globalData.navigationBarHeight + this.globalData.statusBarHeight
  22. // #endif
  23. // console.log('this.globalData==========',this.globalData)
  24. // this.$wxApi.config()
  25. },
  26. onShow: function() {
  27. console.log('App Show')
  28. },
  29. onHide: function() {
  30. console.log('App Hide')
  31. }
  32. }
  33. </script>
  34. <style lang="scss">
  35. @import "@/uni_modules/uview-ui/index.scss";
  36. /*每个页面公共css */
  37. /* #ifdef H5 */
  38. * {
  39. margin: 0;
  40. padding: 0;
  41. }
  42. html,body {
  43. width: 100%;
  44. height: 100%;
  45. }
  46. /* #endif */
  47. </style>