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 deeply nested router-views display the last visited component component #2923

Closed
Labels
bug has PR keep-alive Problem appearing when using keep-alive

Comments

@lxcuso4
Copy link

lxcuso4 commented Sep 8, 2019

Version

3.1.3

Reproduction link

https://jsfiddle.net/lxcuso4/cu6keqw2/28

Steps to reproduce

Click on childA
Click on index
Click on childB

What is expected?

we want to show B page

What is actually happening?

but actually A page dispaly


This behavior happens when we use keep-alive and have three layers of nested routing

@posva
Copy link
Member

posva commented Sep 9, 2019

Similar to #2552 if anybody wants to try fixing this

@posva posva added bug keep-alive Problem appearing when using keep-alive labels Sep 9, 2019
@posva posva changed the title Router resove can't work keep-alive deeply nested router-views display the last visited component component Sep 9, 2019
zrh122 added a commit to zrh122/vue-router that referenced this issue Sep 17, 2019
@songpeng0501
Copy link

I tested that the following code works in src/component/view.js

    var matched = route.matched[depth];
  // render empty node if no matched route
  if (!matched) {
    cache[name] = null;
    return h()
  }
  // render previous view if the tree is inactive and kept-alive
  if (inactive && (cache[name] === matched.components[name])) {
    return h(cache[name], data, children)
  }

you are right

@posva posva added the has PR label Jan 13, 2020
posva pushed a commit to zrh122/vue-router that referenced this issue Jan 14, 2020
posva added a commit that referenced this issue Jan 14, 2020
* fix(router-view): fix deeply nested keep-alive router-views displaying

Fix #2923

* chore: upgrade chromedriver

* refactor(view): add keepAlive check

Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment