You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<template>
|
|
|
|
<router-view #="{ Component, route }">
|
|
|
|
<keep-alive ref="keepAliveRef">
|
|
|
|
<component :is="Component" :key="route.path" />
|
|
|
|
</keep-alive>
|
|
|
|
</router-view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, ref, watch } from 'vue'
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'App',
|
|
|
|
setup() {
|
|
|
|
const keepAliveRef = ref()
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => route.fullPath,
|
|
|
|
() => {
|
|
|
|
// 获取keep-alive缓存
|
|
|
|
const routeCaches = keepAliveRef.value?.$?.__v_cache
|
|
|
|
console.log('keep-alive cache', routeCaches)
|
|
|
|
routeCaches.delete('/')
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
return { keepAliveRef }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
body::-webkit-scrollbar {
|
|
|
|
width: 0;
|
|
|
|
}
|
|
|
|
</style>
|