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

keep-alive include will also cache anonymous components #6938

Closed
PanJiaChen opened this issue Oct 27, 2017 · 4 comments
Closed

keep-alive include will also cache anonymous components #6938

PanJiaChen opened this issue Oct 27, 2017 · 4 comments
Labels

Comments

@PanJiaChen
Copy link

Version

2.5.2

Reproduction link

https://jsfiddle.net/L613xva0/13/

Steps to reproduce

triggle the route

What is expected?

the second route component not be cached

What is actually happening?

the second route component be cached


this demo tow router-view component both have name, the result is right ,
but in this demo, the second route have no name ,but also be cached

The match is first checked on the component’s own name option, then its local registration name (the key in the parent’s components option) if the name option is not available. Anonymous components cannot be matched against.

<keep-alive :include="cachePages">
  <router-view></router-view>
</keep-alive>

when l keep-alive router-view , every anonymous component page will be cached , i don't think is reasonable.

@PanJiaChen PanJiaChen mentioned this issue Oct 30, 2017
8 tasks
cuteyumiko pushed a commit to cuteyumiko/vue that referenced this issue Nov 1, 2017
@yyx990803 yyx990803 added the bug label Nov 17, 2017
rocka added a commit to Rocket1184/electron-netease-cloud-music that referenced this issue Nov 20, 2017
@yuu2lee4
Copy link

yuu2lee4 commented Nov 20, 2017

@yyx990803 Now keep-alive will not cache any anonymous components without include prop,it's a bug or a break change?

@devinRex
Copy link

devinRex commented Nov 20, 2017

The same as @yuu2lee4.

You can see the reproduction in the console panel of this link https://jsfiddle.net/tqfc2edq/

The vue version 2.5.6, and you can see without "include", all anonymous components can't cahce. only mounted , without activated.

@yyx990803
Copy link
Member

Fixed in a23b913

lovelope pushed a commit to lovelope/vue that referenced this issue Feb 1, 2018
This only happens if the component is returned by a intermediate
functional or abstract component, e.g. <router-view>. Fix vuejs#6938.
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
This only happens if the component is returned by a intermediate
functional or abstract component, e.g. <router-view>. Fix vuejs#6938.
@maksnester
Copy link

@yyx990803 but what if I need to cache anonymous component, how can I do that? There is no way? Why not to stick with the key passed to it? For example for that case I would expect this component working under keep-alive:
image

But it doesn't. Because it has no name.

aJean pushed a commit to aJean/vue that referenced this issue Aug 19, 2020
This only happens if the component is returned by a intermediate
functional or abstract component, e.g. <router-view>. Fix vuejs#6938.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants