在项目目录下创建一个utils文件,并在里面创建一个system.js文件。

在system.js中配置如下代码:
const SYSTEM_INFO = uni.getSystemInfoAsync();
// 返回状态栏高度
export const getStatusBarHeight = ()=> SYSTEM_INFO.statusBarHeight || 15;
// 返回胶囊的高度(包括距离状态栏的部分)
export const getTitleBarHeight = ()=>{
if(uni.getMenuButtonBoundingClientRect) {
let {top, height} = uni.getMenuButtonBoundingClientRect();
return height + (top - getStatusBarHeight()) * 2;
}else{
return 40;
}
}
在script标签中引入:
import {getStatusBarHeight, getTitleBarHeight} from "@/utils/system.js";
我们在没有设置状态栏高度和胶囊按钮高度的时候是如下状态:

直接在标签中进行配置:
:style="{height:getStatusBarHeight()+'px'}"
:style="{height:getTitleBarHeight()+'px'}"









![BUUCTF_[安洵杯 2019]easy_web(preg_match绕过/MD5强碰撞绕过/代码审计)](https://i-blog.csdnimg.cn/direct/23f29db82fbe47e580ce351b35c4074d.png)






![python算法和数据结构刷题[1]:数组、矩阵、字符串](https://i-blog.csdnimg.cn/direct/21f81f3f38af47ada982711451fcbe9f.png)


