What is the difference between the F5 refresh of the browser and the vue routing refresh?

background:
vue project stores an object acquired through the interface in vueX

after entering page A, console.log (vueX object) is normally available for output

but after pressing F5 or refreshing the page with a browser, console outputs an empty

.

but if you use the route refresh method console can be output

The method of

output is written in the created hook function

what"s the difference between these two refreshes? in addition, if you want to monitor vuex, it"s best to listen

.
Apr.09,2021

first of all, the subject needs to understand why vue and vue-router are used to build a single-page application.
the second thing to understand is the difference between a single page application and a traditional page.

so a single-page routing jump is a no-refresh jump. On the surface, it looks like an app application, just like the tab tab you wrote. All the data is still in memory, and the page is not overloaded.

What does the

F5 refresh do? reload the page, destroy all the previous data, some data you write in the declaration cycle of some builds, press F5 to refresh with url, those components that load the data may not be loaded at all, the life cycle is not running, where does the data come from


after F5 refresh, the data stored in vuex's state will be initialized. If you want to save it, you can listen to window's reload event and copy a copy of state's data into sessionstroage. I haven't tried, this is just my idea. No, no offense.


F5 refresh is equivalent to re-request page

Router refresh, recreate routing page

the hook provided by the route to listen

Menu