the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > in Uniapp there are many kinds of ways for cached page, here are some might be useful methods:
-
Using the uni-simple-router plug-in
uni-simple-router is a lightweight routing plug-in that provides page caching capabilities. Through this plug-in, you can set the page to be cached in the route configuration. After the page is cached, when it is switched to another page and returned, the page will not be reloaded, but read from the cache. To use this plug-in, you need to install and configure it first. -
Use vuex for state management
In Vue.js, Vuex is a state management library that can be used to globally manage the state of an application. Data that needs to be cached can be stored in Vuex and read from Vuex when pages are switched, thus avoiding page reloading problems. Of course, you need to consider the size of the data stored in Vuex and the impact on performance. -
Local storage using localStorage
localStorage is the local storage API provided by the browser. Data can be stored in the browser, and data can be read from localStorage when the application is opened next time. You can serialize the data that needs to be cached and store it in localStorage, and then deserialize the data when you open the application next time. However, the storage capacity of localStorage is limited. If the data stored in Localstorage is too large, performance may be affected. -
Using sessionStorage for session storage
sessionStorage is similar to localStorage, the difference is that the storage time of sessionStorage is the session duration, that is, when the user closes the browser window or TAB, The data will be erased. Therefore, data that needs to be cached can be stored in sessionStorage and read from the sessionStorage when users switch pages. Note, however, that when the user closes the browser window or TAB, the data will be erased.
All in all, the above are several common methods of caching pages, you can choose your own method according to the actual situation.