App.vue 866 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div id="app">
  3. <router-view v-if="isRouterAlive" />
  4. </div>
  5. </template>
  6. <script>
  7. import "@/assets/iconfont/iconfont.css";
  8. import { initDictToLocalstorage } from "@/api/dict-data";
  9. export default {
  10. name: "App",
  11. provide() {
  12. return {
  13. reload: this.reload
  14. };
  15. },
  16. data() {
  17. return {
  18. isRouterAlive: false
  19. };
  20. },
  21. watch: {
  22. $route(to, form) {
  23. if (to.path == "/login") {
  24. this.queryDictName();
  25. }
  26. }
  27. },
  28. computed: {},
  29. created() {
  30. this.queryDictName();
  31. },
  32. methods: {
  33. queryDictName() {
  34. // 初始化数据字典到浏览器本地缓存
  35. initDictToLocalstorage(() => {
  36. this.isRouterAlive = true;
  37. });
  38. },
  39. reload() {
  40. this.isRouterAlive = false;
  41. this.$nextTick(function() {
  42. this.isRouterAlive = true;
  43. });
  44. }
  45. }
  46. };
  47. </script>