文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-508322.html
mounted() {
// #ifndef H5 || APP-PLUS || MP-ALIPAY
let menuButtonObject = uni.getMenuButtonBoundingClientRect(); //獲取菜單按鈕(右上角膠囊按鈕)的布局位置信息。坐標(biāo)信息以屏幕左上角為原點(diǎn)。
uni.getSystemInfo({ //獲取系統(tǒng)信息
success: res => {
let navHeight = menuButtonObject.height + (menuButtonObject.top - res.statusBarHeight) *
2; //導(dǎo)航欄高度=菜單按鈕高度+(菜單按鈕與頂部距離-狀態(tài)欄高度)*2
// 導(dǎo)航欄(膠囊)高度
this.titleBarHeight = navHeight;
// 狀態(tài)欄(頂部)高度
this.statusBarHeight = res.statusBarHeight
console.log(this.titleBarHeight);
console.log(this.statusBarHeight);
},
fail(err) {
console.log(err);
}
})
// #endif
},
uni.getMenuButtonBoundingClientRect() 參考鏈接
uni.getSystemInfo()參考鏈接文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-508322.html
到了這里,關(guān)于uniapp 小程序自定義導(dǎo)航欄計(jì)算狀態(tài)欄(頂部)與導(dǎo)航欄(膠囊)高度的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!