commonHeader.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="common_header" :style="{ paddingTop: statusBarHeight + 62 + 'rpx' }">
  3. <view class="header_left" @click="handleBack">
  4. <uni-icons type="back" size="24" color="#333333"></uni-icons>
  5. </view>
  6. <text class="header_title">{{ title }}</text>
  7. <view class="header_right">
  8. <slot name="right"></slot>
  9. </view>
  10. </view>
  11. </template>
  12. <script setup>
  13. import { onMounted } from 'vue';
  14. import { useSafeArea } from '@/common/safeArea';
  15. import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
  16. const props = defineProps({
  17. title: {
  18. type: String,
  19. default: ''
  20. }
  21. });
  22. const emit = defineEmits(['back']);
  23. const { statusBarHeight, initSafeArea } = useSafeArea();
  24. onMounted(() => {
  25. initSafeArea();
  26. });
  27. const handleBack = () => {
  28. emit('back');
  29. };
  30. </script>
  31. <style lang="scss" scoped>
  32. .common_header {
  33. position: fixed;
  34. top: 0;
  35. left: 0;
  36. right: 0;
  37. z-index: 100;
  38. display: flex;
  39. align-items: center;
  40. justify-content: space-between;
  41. padding-left: 24rpx;
  42. padding-right: 24rpx;
  43. padding-bottom: 24rpx;
  44. background-color: #FFFFFF;
  45. border-bottom: 2rpx solid #F3F3F3;
  46. .header_left {
  47. width: 48rpx;
  48. }
  49. .header_title {
  50. flex: 1;
  51. text-align: center;
  52. font-weight: 500;
  53. font-size: 32rpx;
  54. color: #333333;
  55. }
  56. .header_right {
  57. width: 48rpx;
  58. }
  59. }
  60. </style>