Page.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div :class="`page ${!props.title? 'page-no-title':''}`">
  3. <van-nav-bar class="header"
  4. v-bind:title="props.title"
  5. v-if="showHeader"
  6. :border="!!props.title"
  7. :style="`height:${usePxToVwView(headerHeight)}`">
  8. <template v-slot:left>
  9. <van-icon @click="goBack" name="revoke" size="1.29rem" color="#000000" class="font-bold" v-if="routerStore.currentPages?.length>1"/>
  10. <slot name="headerLeft"></slot>
  11. </template>
  12. <template v-slot:title>
  13. <span v-if="props.title" class="text-size-large">{{ props.title }}</span>
  14. <slot v-else name="title"></slot>
  15. </template>
  16. <template v-slot:right>
  17. <slot name="headerRight"></slot>
  18. </template>
  19. </van-nav-bar>
  20. <slot name="top"></slot>
  21. <div class="body">
  22. <slot name="body"></slot>
  23. </div>
  24. <slot name="footer"></slot>
  25. </div>
  26. </template>
  27. <script setup>
  28. import useRouterStore from "@/store/useRouterStore.js";
  29. import usePxToVwView from "@hooks/usePxTransform.js";
  30. const routerStore = useRouterStore();
  31. /**
  32. * @description 组件参数
  33. * */
  34. const props = defineProps({
  35. /**
  36. * @property showHeader {Boolean} 是否显示header
  37. * @desc header 页面顶部标题
  38. * */
  39. showHeader: {
  40. type: Boolean,
  41. default: true
  42. },
  43. /**
  44. * @property headerHeight {Number || String} 页面顶部标题高度
  45. * */
  46. headerHeight: {
  47. type: [String, Number],
  48. default: 44
  49. },
  50. /**
  51. * @property title {String} 页面顶部标题
  52. * */
  53. title: String,
  54. });
  55. const goBack = ()=>{
  56. history.back();
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .page{
  61. width: 100%;
  62. height: 100%;
  63. display: flex;
  64. flex-direction: column;
  65. overflow: hidden;
  66. box-sizing: border-box;
  67. font-size: 14px;
  68. color: #333333;
  69. background: #F8F8F8;
  70. }
  71. .body {
  72. height: 100%;
  73. flex: 1;
  74. overflow-x: auto;
  75. }
  76. .no-data, .loading {
  77. height: 100%;
  78. display: flex;
  79. align-items: center;
  80. justify-content: center;
  81. }
  82. .data-loading-complete {
  83. padding: 12px 0;
  84. display: flex;
  85. align-items: center;
  86. justify-content: center;
  87. color: #999999;
  88. }
  89. .page-no-title {
  90. .header {
  91. .back {
  92. color: #ffffff;
  93. }
  94. }
  95. }
  96. :deep(.van-nav-bar__content) {
  97. height: 100% !important;
  98. }
  99. </style>