App.vue 814 B

123456789101112131415161718192021222324252627282930
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. // 获取设备信息
  5. let that = this;
  6. uni.getSystemInfo({
  7. success(res) {
  8. that.$systemInfo.platform = res.platform;
  9. that.$systemInfo.statusBarHeight = res.statusBarHeight;
  10. that.$systemInfo.fontSizeSetting = res.fontSizeSetting;
  11. if (res.platform === 'ios' || res.platform === 'devtools') {
  12. that.$systemInfo.navBarHeight = 44;
  13. } else {
  14. // 获取胶囊按钮信息
  15. let menuInfo = uni.getMenuButtonBoundingClientRect();
  16. // 计算导航栏高度
  17. that.$systemInfo.navBarHeight = menuInfo.height + (menuInfo.top - res.statusBarHeight) * 2;
  18. }
  19. }
  20. });
  21. },
  22. onShow: function() {},
  23. onHide: function() {}
  24. }
  25. </script>
  26. <style>
  27. /*每个页面公共css */
  28. @import './common/uni.css';
  29. </style>