// 计算状态栏高度 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