HomeSection.vue 786 B

123456789101112131415161718192021222324252627282930313233343536
  1. <script setup lang="ts">
  2. import { toRefs, computed, useSlots, h } from "vue";
  3. const props = defineProps<{
  4. title?: string;
  5. }>();
  6. const { title } = toRefs(props);
  7. const slots = useSlots();
  8. const titleNode = computed(() => {
  9. return slots.title ? slots.title() : title.value ? h("h1", {}, title.value) : null;
  10. });
  11. </script>
  12. <template>
  13. <div class="home-section">
  14. <component :is="titleNode" class="title" />
  15. <el-row class="content" justify="center" :gutter="20" tag="section" v-bind="$attrs">
  16. <slot></slot>
  17. </el-row>
  18. </div>
  19. </template>
  20. <style lang="scss" scoped>
  21. .home-section {
  22. display: flex;
  23. flex-direction: column;
  24. align-items: center;
  25. width: 100%;
  26. gap: 20px;
  27. }
  28. .content {
  29. width: 100%;
  30. }
  31. .el-row {
  32. row-gap: 20px;
  33. align-items: stretch;
  34. }
  35. </style>