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

Allow including/excluding by key in keep-alive #2084

Closed
zengyuanqiu opened this issue Sep 10, 2020 · 6 comments
Closed

Allow including/excluding by key in keep-alive #2084

zengyuanqiu opened this issue Sep 10, 2020 · 6 comments
Labels

Comments

@zengyuanqiu
Copy link

zengyuanqiu commented Sep 10, 2020

What problem does this feature solve?

Want more flexible caching components

What does the proposed API look like?

<keep-alive include="detail-id-1,detail-id-2">
        <component :is="Component" :key="key" />
 </keep-alive>

Source code:232 line

  const name = getName(comp);
  const { include, exclude, max } = props;

  if (
    (include && (!name || !matches(include, name))) ||
    (exclude && name && matches(exclude, name))
  ) {
    return (current = vnode)
  }

  const key = vnode.key == null ? comp : vnode.key
  const cachedVNode = cache.get(key)

modify:

  const name = vnode.key || getName(comp)

The "key" value is preferred as the include or exclude condition

@posva
Copy link
Member

posva commented Sep 10, 2020

This was asked for Vue 2 vuejs/vue#8028

@posva posva changed the title KeepAlive Allow including/excluding by key in keep-alive Sep 10, 2020
@yyx990803 yyx990803 added the ✨ feature request New feature or request label Sep 14, 2020
@HcySunYang
Copy link
Member

Closed, tracking here vuejs/rfcs#284

@fightingcat
Copy link

Closed, tracking here vuejs/rfcs#284

Any progress?

@blakjak44
Copy link

Closed, tracking here vuejs/rfcs#284

Is there anything holding this up?

@lifei110196
Copy link

三年又三年

@yuntian001
Copy link

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

Successfully merging a pull request may close this issue.

8 participants