根据tab决定是否keepalive (动态keepalive)

This commit is contained in:
piexlmax
2022-10-30 21:00:57 +08:00
parent 192c0e529d
commit cf5daffe69
3 changed files with 23 additions and 12 deletions
@@ -209,13 +209,6 @@ const setTab = (route) => {
const historyMap = ref({})
watch(() => historys.value, () => {
historyMap.value = {}
historys.value.forEach((item) => {
historyMap.value[getFmtString(item)] = item
})
})
const changeTab = (name) => {
const tab = historyMap.value[name]
router.push({
@@ -274,6 +267,11 @@ watch(() => route, (to, now) => {
watch(() => historys.value, () => {
sessionStorage.setItem('historys', JSON.stringify(historys.value))
historyMap.value = {}
historys.value.forEach((item) => {
historyMap.value[getFmtString(item)] = item
})
emitter.emit('setKeepAlive', historys.value)
}, {
deep: true
})
-1
View File
@@ -82,7 +82,6 @@ getTheme()
const active = ref('')
watch(() => route, () => {
console.log(route.meta.activeName)
active.value = route.meta.activeName || route.name
}, { deep: true })