HTML部分:
<template>
<div class="stateBar">
<view class="bar" :style="{ height: statusBarHeight + 'px' }"></view>
</div>
</template>
CSS部分:
<style lang="scss" scoped>
.bar{
background: skyblue;
}
</style>
JS部分:
<script>
export default {
name: "stateBar",
data() {
return {
statusBarHeight: 20, //状态栏的高度
};
},
created() {
//获取手机系统信息
const systemInfo = uni.getSystemInfoSync();
//获取状态栏信息-h5没有状态栏
this.statusBarHeight = systemInfo.statusBarHeight;
},
};
</script>