If vue makes the page jump back and forth, but the data remains the same.

my current scenario is that the product search page / search?a=b&c=d and the product details page / item/123 are both in the same router-view ;

.

I want the effect is that the list page jumps to the details page, then jumps back, and the list page does not refresh

two pages are routed as follows

children: [
    {
        path: "search",
        name: "search",
        meta: {
            title: "",
            keepAlive: true
        },
        component: _import("xx")
    },
    {
        path: "item/:skuid",
        name: "detail",
        meta: {
            title: "",
            keepAlive: false
        },
        component: _import("xxx")
    }
]

search page listens to $route (the following code), and loads the product list as soon as there are changes.

watch: {
    "$route": {
         handler: "getProduct",
         immediate: true
     }
}

search for keep-alive combined with mate.keepAlive is mentioned on the Internet, but I don"t understand the principle, and the following writing method can"t achieve the desired effect

.
<keep-alive>
    <router-view></router-view>
</keep-alive>

when I use the front-end framework for the first time, I don"t quite understand many concepts. I"m a little confused when I read the document

.

is my thinking wrong, or my writing is wrong? I hope to get some advice. Please


the subject wants to have the caching effect of keep-alive, but if the data changes, update the list, right?

in fact, the trigger order of kepp-alive hooks created- > mounted- > activated, triggers deactivated when exiting. When entering (forward or backward) again, only activated is triggered. vue keep-alive lifecycle description

so, subject, just put the data acquisition logic in the create hook into activated, and it is completely responsive

.

I've done something similar before, using keep-alive, The meta in the route defines whether caching is required:
https://codeshelper.com/q/10.


ide/components-dynamic-async.html" rel= "nofollow noreferrer" > https://cn.vuejs.org/v2/guide.


view outer bread keep-active, in App.vue


< keep-alive include= "answer" >