zhongshujie
2025-08-08 401ed176c9f1bdd97ccdf827d9454b11a3891f79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<template>
  <div class="layoutBox">
    <Header v-if="showHeader" class="header"></Header>
    <div class="layoutContentBox" id="layout">
      <RouterView />
    </div>
    <Footer class="footer"></Footer>
  </div>
</template>
 
<script setup lang="ts">
import { RouterView, useRoute } from 'vue-router'
import Header from './components/headerPage.vue'
import Footer from './components/footerPage.vue'
import { computed } from 'vue';
// 获取当前路由对象
const route = useRoute();
 
// 使用计算属性,根据路由的 meta 信息决定是否显示 Header
// 如果 meta.showHeader 不存在,默认为 true
const showHeader = computed(() => {
  return route.meta.showHeader !== false;
});
 
</script>
 
<style lang="less" scoped>
.layoutBox {
  width: 100%;
  min-width: 1200px;
  height: 100vh;
  display: flex;
  flex-direction: column;
 
  .layoutContentBox {
    flex: 1;
  }
 
  .header {
    flex-shrink: 0;
    width: 100%;
  }
}
</style>