| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <script setup lang="ts">
- const props = withDefaults(
- defineProps<{
- title: string
- showBack?: boolean
- }>(),
- {
- showBack: true,
- },
- )
- const emit = defineEmits<{
- (e: 'back'): void
- }>()
- const router = useRouter()
- const handleBack = () => {
- emit('back')
- router.back()
- }
- </script>
- <template>
- <header class="common-header">
- <button
- v-if="props.showBack"
- type="button"
- class="common-header__back"
- @click="handleBack"
- >
- <van-icon
- name="arrow-left"
- :size="18"
- />
- </button>
- <div
- v-else
- class="common-header__spacer"
- />
- <h1 class="common-header__title">
- {{ props.title }}
- </h1>
- <div class="common-header__spacer">
- <slot name="right" />
- </div>
- </header>
- </template>
- <style scoped lang="scss">
- .common-header {
- position: sticky;
- top: 0;
- z-index: 10;
- height: 44px;
- padding: 0 16px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: #fff;
- }
- .common-header__back {
- border: none;
- padding: 4px;
- border-radius: 999px;
- background: transparent;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .common-header__title {
- font-size: 18px;
- font-weight: 500;
- color: #17171a;
- }
- .common-header__spacer {
- width: 24px;
- height: 24px;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- }
- </style>
|