uniapp 自定义手机顶部状态栏(适配状态栏高度)
直接上代码
<view :style="{ height: statusBarHeight + 'px' }"></view>
//参数
data() {
return {
statusBarHeight:0,
}
},
mounted() {
//必须放在mounted钩子函数最前面,不能放在调用其它方法后面,否则无效
let that = this
//获取手机系统信息
const info = uni.getSystemInfoSync()
//设置状态栏高度
that.statusBarHeight = info.statusBarHeight
},