keepAlive 测试
This commit is contained in:
parent
6b15ba990d
commit
cbd7809291
@ -1,19 +1,24 @@
|
||||
<template>
|
||||
<div class="mx-1">
|
||||
<el-config-provider v-bind="globalConfig">
|
||||
<keep-alive>
|
||||
|
||||
<el-tabs v-model="globalTab" @tab-change="tabChange" @tab-remove="tabRemove">
|
||||
<el-tab-pane
|
||||
v-for="item in globalTabs"
|
||||
:key="item.name"
|
||||
:label="item.title"
|
||||
:closable="item.closable"
|
||||
@close="closeTabPane"
|
||||
:name="item.name">
|
||||
<router-view />
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition>
|
||||
<component v-if="route.meta.keepAlive != null && route.meta.keepAlive === false" :is="Component" />
|
||||
<keep-alive v-else>
|
||||
<component :is="Component" />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</keep-alive>
|
||||
</el-config-provider>
|
||||
</div>
|
||||
</template>
|
||||
@ -23,16 +28,17 @@ import {computed, onBeforeUnmount, onMounted} from "vue";
|
||||
import {createDebugger, destroyDebugger} from "src/utils/debugger/eruda";
|
||||
import {useGlobalConfig} from "src/store/globalConfig";
|
||||
import {useGlobalTabs} from "src/store/globalTabs";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {useRouter} from "vue-router";
|
||||
import {mapWritableState, storeToRefs} from "pinia";
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
|
||||
const globalConfig = computed(()=>useGlobalConfig().$state.ui)
|
||||
const globalConfig = computed(mapWritableState(useGlobalConfig,['ui']).ui)
|
||||
|
||||
const globalTabsState = useGlobalTabs()
|
||||
globalTabsState.$reset()
|
||||
|
||||
const {tab:globalTab, tabs:globalTabs} = storeToRefs(globalTabsState)
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
router.push({
|
||||
path: "/"
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user