PageHeader.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="page-header">
  3. <view class="status-bar"></view>
  4. <view class="navbar" :style=" cssStyle ">
  5. <view class="navbar-left">
  6. <view class="back-icon" @click="goBack">
  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. },
  33. methods: {
  34. goBack() {
  35. uni.navigateBack({
  36. delta: 1
  37. });
  38. }
  39. }
  40. }
  41. </script>
  42. <style lang="scss" scoped>
  43. .page-header {
  44. position: fixed;
  45. top: 0;
  46. left: 0;
  47. width: 100%;
  48. z-index: 100;
  49. background-color: #ffffff;
  50. }
  51. .status-bar {
  52. height: var(--status-bar-height);
  53. }
  54. .navbar {
  55. display: flex;
  56. align-items: center;
  57. height: 90rpx;
  58. padding: 0 30rpx;
  59. }
  60. .navbar-left {
  61. width: 120rpx;
  62. }
  63. .navbar-title {
  64. flex: 1;
  65. text-align: center;
  66. font-size: 36rpx;
  67. font-weight: bold;
  68. display: flex;
  69. align-items: center;
  70. justify-content: center;
  71. }
  72. .navbar-right {
  73. width: 120rpx;
  74. text-align: right;
  75. }
  76. .back-icon {
  77. width: 40rpx;
  78. height: 40rpx;
  79. }
  80. </style>