首页 > 其他分享 >uniapp 獲取状态栏 + 胶囊高度

uniapp 獲取状态栏 + 胶囊高度

时间:2022-10-15 16:44:58浏览次数:36  
标签:uniapp 獲取 状态栏 ztl 胶囊 高度 custom

  // 计算状态栏高度
            getMenuButton() {
                // 状态栏高度
                let ztl = uni.getSystemInfoSync().statusBarHeight;
                // 获取微信胶囊的位置信息
                const custom = wx.getMenuButtonBoundingClientRect()
                // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
                let ztlh2 = custom.height + (custom.top - ztl) * 2
                // 总体高度 = 状态栏高度 + 导航栏高度
                getApp().globalData.topHeight = ztl + ztlh2
                console.log(getApp().globalData.topHeight);
            }
View Code

 

标签:uniapp,獲取,状态栏,ztl,胶囊,高度,custom
From: https://www.cnblogs.com/bi-hu/p/16794482.html

相关文章