index.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <div ref="viewRef" class="app-view" :class="[`bg-${background}`]">
  3. <slot name="header"></slot>
  4. <app-scroll-view :class="{ 'app-view__body': true, 'flex': flex }">
  5. <Loading class="app-view__loading" v-if="loading" />
  6. <slot></slot>
  7. </app-scroll-view>
  8. <slot name="footer"></slot>
  9. </div>
  10. </template>
  11. <script lang="ts" setup>
  12. import { shallowRef, onMounted, PropType } from 'vue'
  13. import { Loading } from 'vant'
  14. defineProps({
  15. // 显示一个加载动画
  16. loading: {
  17. type: Boolean,
  18. default: false
  19. },
  20. // 是否启用弹性布局
  21. flex: {
  22. type: Boolean,
  23. default: false
  24. },
  25. // 背景颜色
  26. background: {
  27. type: String as PropType<'default' | 'primary'>,
  28. default: 'default'
  29. },
  30. })
  31. const emit = defineEmits(['ready'])
  32. const viewRef = shallowRef()
  33. onMounted(() => {
  34. emit('ready', viewRef.value)
  35. })
  36. </script>
  37. <style lang="less">
  38. @import './index.less';
  39. </style>