When vue keep-alive cooperates with routing, the content of An is cached when it is used to realize the page of A Murray B, which is displayed later.

how do ue keep-alive cooperate with routing to implement the page of Amurb, cache the content of A, and then display it

keep-alive and beforerouterLeave or beforerouterenter

Mar.02,2021

set under A:

beforeRouteLeave( to, from, next) {
    if(to.name === B) {
        from.meta.keepAlive == true
    }
}

keep-alive automatically records the location and saves the cached content. There is no need to do it deliberately. before , keep-alive is the caching mode, and the cached page content will be saved automatically, but you need to know when you want to figure it out

.
Menu