fix: 路由切换组件不渲染的问题&切换为 hash 路由

This commit is contained in:
baiqi 2023-06-01 17:56:58 +08:00 committed by rubylliu
parent b4528fbf89
commit 8accf388ca
2 changed files with 8 additions and 6 deletions

View File

@ -1,10 +1,12 @@
<template>
<router-view v-slot="{ Component, route }">
<transition name="fade" mode="out-in" appear>
<component :is="Component" v-if="route.meta.ignoreCache" :key="route.fullPath" />
<keep-alive v-else :include="cacheList">
<component :is="Component" :key="route.fullPath" />
</keep-alive>
<div>
<component :is="Component" v-if="route.meta.ignoreCache" :key="route.fullPath" />
<keep-alive v-else :include="cacheList">
<component :is="Component" :key="route.fullPath" />
</keep-alive>
</div>
</transition>
</router-view>
</template>

View File

@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router';
import { createRouter, createWebHashHistory } from 'vue-router';
import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css';
@ -9,7 +9,7 @@ import createRouteGuard from './guard';
NProgress.configure({ showSpinner: false }); // NProgress Configuration
const router = createRouter({
history: createWebHistory(),
history: createWebHashHistory(),
routes: [
{
path: '/',