添加方法:获取导航栏高度、屏幕高度
This commit is contained in:
parent
3724cd5f3d
commit
ed3309fcd1
@ -116,3 +116,35 @@ export function isNullOrEmpty(value){
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取导航栏高度
|
||||||
|
export function getNavHeight(callback) {
|
||||||
|
// 获取胶囊按钮信息
|
||||||
|
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: (res) => {
|
||||||
|
const statusBarHeight = res.statusBarHeight;
|
||||||
|
const navHeight =
|
||||||
|
statusBarHeight +
|
||||||
|
menuButtonInfo.height +
|
||||||
|
(menuButtonInfo.top - statusBarHeight) * 2;
|
||||||
|
callback(navHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getScreenHeightNoTabBar(callback){
|
||||||
|
// 获取胶囊按钮信息
|
||||||
|
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: (res) => {
|
||||||
|
const {statusBarHeight,windowHeight,screenHeight}=res;
|
||||||
|
const navHeight =
|
||||||
|
statusBarHeight +
|
||||||
|
menuButtonInfo.height +
|
||||||
|
(menuButtonInfo.top - statusBarHeight) * 2;
|
||||||
|
const height=screenHeight-navHeight;
|
||||||
|
callback(height);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user