uniapp自定义头部任务栏,任务栏高度自适应问题

浏览976

非H5端,手机顶部状态栏区域会被页面内容覆盖。这是因为窗体是沉浸式的原因,即全屏可写内容。uni-app提供了状态栏高度的css变量--status-bar-height,如果需要把状态栏的位置从前景部分让出来,可写一个占位div,高度设为css变量。

<template>
  <view>
      <view>
          <!-- 这里是状态栏 -->
      </view>
      <view> 状态栏下的文字 </view>
  </view>
</template>   
<style>
  .status_bar {
      height: var(--status-bar-height);
      width: 100%;
  }
</style>

image.png


  • 暂无任何回答