ax-body.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <view class="ax ax-body" :style="[StyleSheet]">
  3. <ax-custom-title v-if="$slots.title" @display="$emit('display', $event)">
  4. <slot name="title"></slot>
  5. </ax-custom-title>
  6. <ax-custom-title v-else @display="$emit('display', $event)"></ax-custom-title>
  7. <view class="__root">
  8. <slot></slot>
  9. </view>
  10. <ax-ios-indicator v-if="hideIndicatorArea == false"></ax-ios-indicator>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "ax-body",
  16. props: {
  17. // 两侧留白范围
  18. blank: { type: [Number, String], default: 10 },
  19. // 隐藏指示器范围占位
  20. hideIndicatorArea: { type: Boolean, default: false }
  21. },
  22. mounted() {
  23. uni.createSelectorQuery().in(this).select(".__root").boundingClientRect((data) => {
  24. if (data) this.$emit('init', data);
  25. }).exec();
  26. },
  27. computed: {
  28. StyleSheet() {
  29. return {
  30. '--blank': `${Number(this.blank) || 0}px`
  31. }
  32. }
  33. }
  34. }
  35. </script>
  36. <style>
  37. .ax-body {
  38. display: flex;
  39. flex-direction: column;
  40. height: 100%;
  41. }
  42. .ax-body .__root {
  43. flex: 1;
  44. overflow: auto;
  45. padding-left: var(--blank) !important;
  46. padding-right: var(--blank) !important;
  47. }
  48. ax-custom-title {
  49. position: relative;
  50. z-index: 99999999;
  51. }
  52. </style>