fs-container.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view class="fs-container">
  3. <view class="fs-container-header"><slot name="header"></slot></view>
  4. <view class="fs-container-main" :style="{ paddingTop: top + 'px', paddingBottom: bottom + 'px' }">
  5. <slot></slot>
  6. </view>
  7. <view class="fs-container-footer"><slot name="footer"></slot></view>
  8. </view>
  9. </template>
  10. <script>
  11. /**
  12. * 容器组件
  13. * @description 容器组件
  14. */
  15. export default {
  16. name: 'fs-container',
  17. data() {
  18. return {
  19. top: 0,
  20. bottom: 0
  21. }
  22. },
  23. mounted() {
  24. uni
  25. .createSelectorQuery()
  26. .in(this)
  27. .select('.fs-container-header')
  28. .boundingClientRect(data => {
  29. this.top = data.height
  30. })
  31. .exec()
  32. uni
  33. .createSelectorQuery()
  34. .in(this)
  35. .select('.fs-container-footer')
  36. .boundingClientRect(data => {
  37. this.bottom = data.height
  38. })
  39. .exec()
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .fs-container {
  45. &-header {
  46. position: fixed;
  47. top: var(--window-top);
  48. left: 0;
  49. right: 0;
  50. z-index: 100;
  51. }
  52. &-footer {
  53. position: fixed;
  54. left: 0;
  55. right: 0;
  56. bottom: var(--window-bottom);
  57. z-index: 100;
  58. }
  59. }
  60. </style>