App.vue 723 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import { updateDocumentTitle } from '@/utils/document-title-util';
  8. export default {
  9. name: 'App',
  10. created() {
  11. console.log(
  12. '我是'
  13. );
  14. // 恢复主题
  15. this.$store.dispatch('theme/recoverTheme');
  16. },
  17. methods: {
  18. /* 路由切换更新浏览器标题 */
  19. setDocumentTitle() {
  20. updateDocumentTitle(
  21. this.$route,
  22. (key) => this.$t(key),
  23. this.$store.state.theme.tabs
  24. );
  25. }
  26. },
  27. watch: {
  28. '$i18n.locale'() {
  29. this.setDocumentTitle();
  30. },
  31. $route() {
  32. this.setDocumentTitle();
  33. }
  34. }
  35. };
  36. </script>