StatusBar.vue 872 Bytes
<template>
  <view class="status_bar" :style="{height:height + 'px','background-color': bgColor}" ></view>
  <view class="block" :style="{height: height+'px','background-color': bgColor}"></view>
</template>

<script setup>
  import {
    onMounted,
    ref
  } from 'vue';
  defineProps({
    bgColor:{
      type:String,
      default:'rgba(0,0,0,0)'
    }
  })
  // h5默认设置为0
  const height = ref(uni.getSystemInfoSync().statusBarHeight || 0)
  // onMounted(() => {
  //   // #ifdef APP
  //   height.value = plus.navigator.getStatusbarHeight()
  //   // #endif

  //   // #ifdef MP-WEIXIN
  //   height.value = 25
  //   // #endif
  // })
</script>

<style>
  .status_bar {
    width: 750rpx;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    /* background-color: transparent; */
    /* background-color: rgba(255,0,0,0.3); */
  }
</style>