hejianhao
2025-01-10 e6eb5dccecce12a0b6dacf21c8fa2904c896dbaa
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
<!-- 如果在空白页打开则不显示框架 -->
<template>
  <router-view />
</template>
 
<script>
import AppContent from './components/AppContent.vue'
export default {
  data() {
    return {
      // 获取当前页面名称
      nowRouteName: '',
    }
  },
  components: {
    AppContent,
  },
  mounted() {
    // 设置标题
    this.setNowRouteName(this.$route)
  },
  methods: {
    // 获取当前页面标题
    setNowRouteName(route) {
      this.nowRouteName = route.meta.title
    },
  },
  watch: {
    // 监听route变化
    $route: function (newVal) {
      this.setNowRouteName(newVal)
    },
  },
}
</script>
 
<style lang="less" scoped></style>