index.js 615 B

123456789101112131415161718192021
  1. /**
  2. * 获取导航栏高度
  3. */
  4. export const getNavBarHeight = () =>{
  5. return new Promise((resolve, reject) => {
  6. // 在 App.vue 中初始化
  7. uni.getSystemInfo({
  8. success: (res) => {
  9. const statusBarHeight = res.statusBarHeight;
  10. console.log('res.platform',res.platform);
  11. const navBarHeight =
  12. (res.platform === 'android' ? 48 : 44) + res.statusBarHeight;
  13. resolve( { statusBarHeight, navBarHeight })
  14. },
  15. fail: (err) => {
  16. reject(err)
  17. }
  18. })
  19. })
  20. }