嵌套 route 调整

This commit is contained in:
shikong 2024-02-18 19:46:27 +08:00
parent 6d539a3055
commit fd30f84af5
6 changed files with 13 additions and 5 deletions

View File

@ -16,7 +16,7 @@
"pinia": "^2.0.21", "pinia": "^2.0.21",
"vue": "^3.2.38", "vue": "^3.2.38",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-router": "^4.1.5" "vue-router": "^4.2.5"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^16.11.56", "@types/node": "^16.11.56",

View File

@ -1 +1 @@
7dc8355d48f99175c4067c253750bda0 15a19573e5ac860a508a6ee2598ed3e8

View File

@ -6,6 +6,10 @@ import {useGlobalConfig} from "@/stores/globalConfig";
import {watch,onBeforeUnmount } from "vue"; import {watch,onBeforeUnmount } from "vue";
import {useMagicKeys, whenever} from "@vueuse/core"; import {useMagicKeys, whenever} from "@vueuse/core";
import {destroyDebugger, switchDebugger} from "@/utils/debugger/eruda"; import {destroyDebugger, switchDebugger} from "@/utils/debugger/eruda";
import {useRoute} from "vue-router";
let routeLocationNormalizedLoaded = useRoute();
console.log(routeLocationNormalizedLoaded)
const {t, availableLocales: languages, locale} = useI18n(); const {t, availableLocales: languages, locale} = useI18n();
let globalConfig = useGlobalConfig(); let globalConfig = useGlobalConfig();
@ -82,7 +86,7 @@ document.body.addEventListener("click", function (event) {
<el-config-provider v-bind="elementUIConfig"> <el-config-provider v-bind="elementUIConfig">
<el-select></el-select> <el-select></el-select>
<router-view v-slot="{ Component, route }"> <router-view v-slot="{ Component, route }">
<component v-if="!route.children" :is="Component"/> <component v-if="route.matched && route.matched.length > 0 && route.matched[0].children.length === 0" :is="Component"/>
<transition v-else name="fade" mode="out-in"> <transition v-else name="fade" mode="out-in">
<div style="height: 100vh" class="overflow-auto"> <div style="height: 100vh" class="overflow-auto">
<component <component

View File

@ -8,6 +8,7 @@ const router = createRouter({
path: "/", path: "/",
name: "home", name: "home",
component: HomeView, component: HomeView,
children: []
}, },
{ {
path: "/about", path: "/about",

View File

@ -6,8 +6,11 @@
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]
}, },
"allowJs": true,
"strict": false, "strict": false,
"noImplicitAny": false "noImplicitAny": false,
"noUnusedLocals": false,
"strictNullChecks": false
}, },
"references": [ "references": [

View File

@ -2959,7 +2959,7 @@ vue-i18n@^9.2.2:
"@intlify/shared" "9.9.1" "@intlify/shared" "9.9.1"
"@vue/devtools-api" "^6.5.0" "@vue/devtools-api" "^6.5.0"
vue-router@^4.1.5: vue-router@^4.2.5:
version "4.2.5" version "4.2.5"
resolved "https://registry.npmmirror.com/vue-router/-/vue-router-4.2.5.tgz#b9e3e08f1bd9ea363fdd173032620bc50cf0e98a" resolved "https://registry.npmmirror.com/vue-router/-/vue-router-4.2.5.tgz#b9e3e08f1bd9ea363fdd173032620bc50cf0e98a"
integrity sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw== integrity sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==