-
zhangwei
2025-03-05 16213c0f85aa3ac8317797bf4a05fd12940e16d3
src/uni_modules/uview-plus/components/u-status-bar/u-status-bar.vue
@@ -2,6 +2,7 @@
   <view
       :style="[style]"
       class="u-status-bar"
      :class="[isH5 && 'u-safe-area-inset-top']"
   >
      <slot />
   </view>
@@ -11,7 +12,7 @@
   import { props } from './props';
   import { mpMixin } from '../../libs/mixin/mpMixin';
   import { mixin } from '../../libs/mixin/mixin';
   import { addUnit, addStyle, deepMerge, sys } from '../../libs/function/index';
   import { addUnit, addStyle, deepMerge, getWindowInfo } from '../../libs/function/index';
   /**
    * StatbusBar 状态栏占位
    * @description 本组件主要用于状态填充,比如在自定导航栏的时候,它会自动适配一个恰当的状态栏高度。
@@ -25,13 +26,24 @@
      mixins: [mpMixin, mixin, props],
      data() {
         return {
            isH5: false
         }
      },
      created() {
         // #ifdef H5
         this.isH5 = true
         // #endif
      },
      computed: {
         style() {
            const style = {}
            // 状态栏高度,由于某些安卓和微信开发工具无法识别css的顶部状态栏变量,所以使用js获取的方式
            style.height = addUnit(sys().statusBarHeight, 'px')
            let sheight = getWindowInfo().statusBarHeight
            if (sheight == 0) {
               this.isH5 = true
            } else {
               style.height = addUnit(sheight, 'px')
            }
            style.backgroundColor = this.bgColor
            return deepMerge(style, addStyle(this.customStyle))
         }