feat:初始提交uni-app项目
This commit is contained in:
45
utils/system.js
Normal file
45
utils/system.js
Normal file
@@ -0,0 +1,45 @@
|
||||
//获取状态栏高度
|
||||
const SYSTEM_INFO = uni.getSystemInfoSync();
|
||||
// 获取高度失败的话就返回默认值 0
|
||||
// 获取状态栏高度
|
||||
export const getStatusBarHeight = ()=> SYSTEM_INFO.statusBarHeight || 0
|
||||
|
||||
//获取预览页面的状态栏
|
||||
export const getPreviewBarHeight = ()=>{
|
||||
// 下面是获取胶囊按钮全部信息
|
||||
// let MENU_BUTTON = uni.getMenuButtonBoundingClientRect();
|
||||
|
||||
//如果有胶囊按钮,我们才进行操作,否则返回一个固定的值
|
||||
if(uni.getMenuButtonBoundingClientRect){
|
||||
//我们使用解构的方法来选取所需的特定内容就可以了
|
||||
let {top} = uni.getMenuButtonBoundingClientRect();
|
||||
// 标题栏的高度
|
||||
let PreviewBarHeight = top
|
||||
return PreviewBarHeight
|
||||
}
|
||||
else{
|
||||
return 40;
|
||||
}
|
||||
}
|
||||
|
||||
//获取标题栏高度
|
||||
export const getTitleBarHeight = ()=>{
|
||||
// 下面是获取胶囊按钮全部信息
|
||||
// let MENU_BUTTON = uni.getMenuButtonBoundingClientRect();
|
||||
|
||||
//如果有胶囊按钮,我们才进行操作,否则返回一个固定的值
|
||||
if(uni.getMenuButtonBoundingClientRect){
|
||||
//我们使用解构的方法来选取所需的特定内容就可以了
|
||||
let {top,height} = uni.getMenuButtonBoundingClientRect();
|
||||
// 标题栏的高度
|
||||
let titleBarHeight = (top - getStatusBarHeight())*2 + height
|
||||
return titleBarHeight
|
||||
}
|
||||
else{
|
||||
return 40;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//获取整个导航栏高度,用于fill栏
|
||||
export const getNavBarHeight = ()=> getTitleBarHeight() + getStatusBarHeight();
|
||||
Reference in New Issue
Block a user