MobileHeader.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <header class="mobile-header">
  3. <button class="back-button" @click="goHome">
  4. <img src="@/assets/index/2.jpg" alt="回到首页" class="back-icon">
  5. </button>
  6. <h1 class="page-title">{{ title }}</h1>
  7. <button v-if="showMenu" class="hamburger-btn" @click="$emit('menu')">
  8. <span class="line"></span>
  9. <span class="line"></span>
  10. <span class="line"></span>
  11. </button>
  12. </header>
  13. </template>
  14. <script setup>
  15. import { useRouter } from 'vue-router'
  16. defineProps({
  17. title: {
  18. type: String,
  19. default: ''
  20. },
  21. showMenu: {
  22. type: Boolean,
  23. default: true
  24. }
  25. })
  26. const router = useRouter()
  27. const goHome = () => {
  28. router.push('/')
  29. }
  30. </script>
  31. <style scoped lang="less">
  32. .mobile-header {
  33. display: flex;
  34. align-items: center;
  35. justify-content: center;
  36. padding: 12px 16px;
  37. background: white;
  38. border-bottom: 1px solid #e5e5e5;
  39. position: relative;
  40. // z-index: 998 !important;
  41. }
  42. .back-button {
  43. position: absolute;
  44. left: 16px;
  45. background: transparent;
  46. border: none;
  47. cursor: pointer;
  48. .back-icon {
  49. width: 40px;
  50. height: 40px;
  51. }
  52. }
  53. .page-title {
  54. font-size: 24px;
  55. font-weight: 600;
  56. color: #1a1a1a;
  57. margin: 0;
  58. }
  59. .hamburger-btn {
  60. position: absolute;
  61. right: 16px;
  62. background: transparent;
  63. border: none;
  64. width: 32px;
  65. height: 24px;
  66. display: flex;
  67. flex-direction: column;
  68. align-items: center;
  69. justify-content: space-between;
  70. padding: 0;
  71. cursor: pointer;
  72. .line {
  73. width: 100%;
  74. height: 2px;
  75. background: #2563EB;
  76. border-radius: 2px;
  77. }
  78. }
  79. </style>