PageHeader.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="PageHeader">
  3. <view class="status-bar"></view>
  4. <view class="navbar" :style="cssStyle">
  5. <view class="navbar-left">
  6. <view class="back-icon" @click="isBack ? goBack() : back()">
  7. <uni-icons type="left" size="20" color="#000000"></uni-icons>
  8. </view>
  9. </view>
  10. <view class="navbar-title">
  11. {{ title }}
  12. <slot name="center"></slot>
  13. </view>
  14. <view class="navbar-right">
  15. <slot name="right"></slot>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'PageHeader',
  23. props: {
  24. title: {
  25. type: String,
  26. default: ''
  27. },
  28. cssStyle: {
  29. type: Object,
  30. default: () => ({})
  31. },
  32. isBack: {
  33. type: Boolean,
  34. default: true
  35. }
  36. },
  37. methods: {
  38. goBack() {
  39. uni.navigateBack({
  40. delta: 1
  41. });
  42. },
  43. back() {
  44. this.$emit('back');
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .PageHeader {
  51. position: fixed;
  52. top: 0;
  53. left: 0;
  54. width: 100%;
  55. z-index: 100;
  56. background-color: #ffffff;
  57. }
  58. .status-bar {
  59. height: var(--status-bar-height);
  60. }
  61. .navbar {
  62. display: flex;
  63. align-items: center;
  64. height: 90rpx;
  65. padding: 0 30rpx;
  66. }
  67. .navbar-left {
  68. width: 120rpx;
  69. }
  70. .navbar-title {
  71. flex: 1;
  72. text-align: center;
  73. font-size: 36rpx;
  74. font-weight: bold;
  75. display: flex;
  76. align-items: center;
  77. justify-content: center;
  78. }
  79. .navbar-right {
  80. width: 120rpx;
  81. text-align: right;
  82. }
  83. .back-icon {
  84. width: 40rpx;
  85. height: 40rpx;
  86. }
  87. </style>