App.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script>
  2. export default {
  3. globalData: {
  4. statusBarHeight: 0, // 状态导航栏高度
  5. navHeight: 0, // 总体高度
  6. navigationBarHeight: 0, // 导航栏高度(标题栏高度)
  7. },
  8. onLaunch: function() {
  9. console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
  10. console.log('App Launch')
  11. console.log("App Launch")
  12. // 状态栏高度
  13. this.globalData.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
  14. // #ifdef MP-WEIXIN
  15. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  16. const custom = wx.getMenuButtonBoundingClientRect()
  17. // console.log(custom)
  18. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  19. this.globalData.navigationBarHeight = custom.height + (custom.top - this.globalData.statusBarHeight) * 2
  20. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  21. // 总体高度 = 状态栏高度 + 导航栏高度
  22. this.globalData.navHeight = this.globalData.navigationBarHeight + this.globalData.statusBarHeight
  23. // #endif
  24. console.log(this.globalData)
  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. /*每个页面公共css */
  36. @import "@/uni_modules/uview-ui/index.scss";
  37. @import '@/uni_modules/uni-scss/index.scss';
  38. // @import '/static/iconfont/iconfont.css';
  39. @import '@/static/styles/index.scss';
  40. /* #ifndef APP-NVUE */
  41. @import '@/static/customicons.css';
  42. // 设置整个项目的背景色
  43. page {
  44. background-color: #f5f5f5;
  45. }
  46. /* #endif */
  47. .example-info {
  48. font-size: 14px;
  49. color: #333;
  50. padding: 10px;
  51. }
  52. .footer{
  53. display:fixed;
  54. bottom:40px;
  55. text-align:center;
  56. }
  57. .flex{
  58. display:flex;
  59. }
  60. </style>