App.vue 755 B

123456789101112131415161718192021222324252627282930313233343536
  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. this.$store.dispatch('theme/recoverTheme');
  14. },
  15. methods: {
  16. /* 路由切换更新浏览器标题 */
  17. setDocumentTitle () {
  18. updateDocumentTitle(
  19. this.$route,
  20. (key) => this.$t(key),
  21. this.$store.state.theme.tabs
  22. );
  23. }
  24. },
  25. watch: {
  26. '$i18n.locale' () {
  27. this.setDocumentTitle();
  28. },
  29. $route () {
  30. this.setDocumentTitle();
  31. }
  32. }
  33. };
  34. </script>