index.js 546 B

12345678910111213141516171819
  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. const navBarHeight =
  11. res.platform === 'android' ? 48 : 44 + res.statusBarHeight;
  12. resolve( { statusBarHeight, navBarHeight })
  13. },
  14. fail: (err) => {
  15. reject(err)
  16. }
  17. })
  18. })
  19. }