graceImmersedStatusbar.vue 584 B

12345678910111213141516171819202122232425262728
  1. <template>
  2. <view>
  3. <view class="graceImmersedStatusbar" :style="{background:bgColor, height:height}"></view>
  4. <view :style="{height:height, width:'100%'}"></view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. props:{
  10. bgColor : {
  11. type : String,
  12. default : "#FFF"
  13. }
  14. },
  15. data(){
  16. return{
  17. height : 0
  18. }
  19. },
  20. created:function(){
  21. var res = uni.getSystemInfoSync();
  22. this.height = res.statusBarHeight + 'px';
  23. }
  24. }
  25. </script>
  26. <style scoped>
  27. .graceImmersedStatusbar{height:20px; position:fixed; z-index:1; top:0; left:0; width:100%;}
  28. </style>