When the page is refreshed, the VUE instance is reloaded, and the store will be reset. The store can be stored in the local localStorage, sessionStorage and cookie before the definition is refreshed. The localStorage is permanent storage, and the page data that was opened last time will be read when the page is reopened. According to my needs, the most appropriate is sessionStorage.
before upload fires when the page is refreshed. You can listen to this method to store the page to sessionStorage before the page is refreshed. Even when page refresh
of course, read the sessionStorage data into the store, read and stored, are written in the app. Vue.
export default {
name: 'app',
created () {
// Read sessionStorage on page load
if (sessionStorage.getItem('store')) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))))
}
// Save the store to sessionStorage when the page is refreshed
window.addEventListener('beforeunload', () => {
sessionStorage.setItem('store', JSON.stringify(this.$store.state))
})
}
}
Read More:
- How many pieces of data can list store in Java?
- The requested page cannot be accessed because the related configuration data for the page is invalid
- How to Fix Sklearn ValueError: This solver needs samples of at least 2 classes in the data, but the data
- Vue Install Store Error: ‘options’ is defind but never used [How to Solve]
- Click the button to use in the react project window.open Methods open a new page and click the data again
- How to fix “Outlook data file cannot be accessed” error (Solved)
- After Vue is packaged, a blank page appears, an error is reported in the resource request, and there is no error handling scheme
- Vue project error: uncaught typeerror: vuex__ WEBPACK_ IMPORTED_ MODULE_ 1__ . default.store is not a constructor
- Android’s viewpager slides to determine whether the current stop page is the last page
- The registered version of ArcEngine can edit the data in SDE (How to Fix 0x80040356 Error)
- How to Solve BFSVC Error: Could not open the BCD template store.
- How to Fix Parser rerror: error tokenizing data. C error: expected 2 fields in line 53, saw 3
- How to Fix Session is not Connecting (How to Diagnose it)
- Vue — run ‘NPM audit fix’ to fix them, or ‘NPM audit’ for details appears when initializing the installation
- Storing JSON data in session storage
- How to Fix TypeError: Cannot cast array data from dtype(‘float64‘) to dtype(‘<U32‘)….
- When writing a website, Vue + Flash prompts network error when visiting Vue page
- Web Crawler: How to get the data in the web page and disguise the header, disguise as a browser to visit many times, avoid a single visit leading to IP blocked
- An error is reported when passing data pages using Ajax: Vue is not defined
- Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded (How to Fix)