Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCurrentInstance().ctx.$refs.keepAlive.$.__v_cache, can not run in prod #5560

Closed
neoech opened this issue Mar 10, 2022 · 2 comments
Closed

Comments

@neoech
Copy link

neoech commented Mar 10, 2022

What problem does this feature solve?

When I want to close tabs, I delete the corresponding route cache in this way

What does the proposed API look like?

<router-view v-slot="{ Component, route }"> <keep-alive ref="keepAlive"> <component :is="Component" :key="route.fullPath" v-if="$route.meta?.keepAlive" /> </keep-alive> <component :is="Component" :key="route.fullPath" v-if="!$route.meta?.keepAlive" /> </router-view>

<script lang="ts" setup> const ins = getCurrentInstance() as any; let removeCache: Function; onMounted(() => { removeCache = (key) => { const keepAliveInstance = ins.ctx.$refs.keepAlive.$; const cache = keepAliveInstance.__v_cache; cache.delete(key); }; }); </script>
The tabs tag close event executes this function, delete the corresponding route cache in this way

@caozhong1996
Copy link
Contributor

About custom caching strategy, it does many people need😔
#4339 #5105

@LinusBorg
Copy link
Member

Then let's keep it in those issues.

Here, you are messing with an internal API and you are on your own, at your own risk.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants