解决若依Vue3前后端分离,路由切换时显示白屏
- 共 724 次检阅

路由切换时显示白屏,不加载后台也不报BUG,

找到AppMain.vue文件,在src/layout/components/下

CSS部分保留,其它的替换成下面的内容

<template>
  <section class="app-main">
    <router-view v-slot="{ Component, route }" :key="routeKey">
      <transition name="fade-transform" mode="out-in">
        <keep-alive :include="tagsViewStore.cachedViews">
          <component
              v-if="!route.meta.link"
              :is="Component"
              :key="route.path"
          />
        </keep-alive>
      </transition>
    </router-view>
    <iframe-toggle />
  </section>
</template>
 
<script setup>
import { useRoute } from 'vue-router';
import iframeToggle from './IframeToggle/index';
import useTagsViewStore from '@/store/modules/tagsView';
const route = useRoute();
const routeKey = computed(() => route.path + Math.random());
 
 
const tagsViewStore = useTagsViewStore();
</script>

 

分享到:

这篇文章还没有评论

发表评论