graceHeader.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view>
  3. <view class="grace-header"
  4. :style="{background:background, height:height+'rpx', 'padding-top':top+'px', zIndex:zIndex}">
  5. <view class="grace-header-main"><slot></slot></view>
  6. <view :style="{width:BoundingWidth, height:'10px'}"></view>
  7. </view>
  8. <!-- 占位 view -->
  9. <view :style="{height:viewHeight+'px'}" v-if="isSeize"></view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. background:{
  16. type : String,
  17. default : "#F8F8F8"
  18. },
  19. height:{
  20. type : Number,
  21. default : 90
  22. },
  23. haveStatusBar:{
  24. type : Boolean,
  25. default : true
  26. },
  27. zIndex : {
  28. type:Number,
  29. default : 99
  30. },
  31. isSeize: {
  32. type: Boolean,
  33. default: true
  34. }
  35. },
  36. data(){
  37. return{
  38. top : 0,
  39. viewHeight : 0,
  40. BoundingWidth :'0px'
  41. }
  42. },
  43. created:function(){
  44. // #ifndef MP-ALIPAY
  45. var res = uni.getSystemInfoSync();
  46. this.top = res.statusBarHeight;
  47. this.viewHeight = this.top + uni.upx2px(this.height);
  48. // #ifdef MP-WEIXIN
  49. // 小程序胶囊按钮
  50. var res = uni.getMenuButtonBoundingClientRect();
  51. this.BoundingWidth = (res.width + 20) + 'px';
  52. // #endif
  53. // #endif
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .grace-header{width:100%; position:fixed; left:0; top:0; z-index:99; height:44px; padding-top:20px; display:flex; flex-direction:row; flex-wrap:nowrap;}
  59. .grace-header-main{width:300rpx; flex:auto;}
  60. </style>