vuex stores the state, which represents the data corresponding to the view, and the storage location is in the memory;
Localstorage is an interface provided by the browser that allows you to save files and disks on your computer. Of course, you can also save the status locally!
They are completely two things. vuex is the state management mechanism in Vue, which facilitates communication between components; and localstorage is local storage, which is a method of storing data in the browser. It is generally used when transferring data across pages.
They are completely different things. Vuex is used for state management, which is the type of component data sharing. Data changes in one component will be mapped to other components that use this data. Let’s talk about localstorage, which is a simpler data storage method provided by H5. Previously, cookies were used to store data, but the amount of data stored in cookies was too small, and the interface was cumbersome. Localstorage data can have a limit of 5M, which is quite large, and the API is quite simple, easy to remember and easy to use. I believe it will become mainstream in the future.
xsf——1991 has already said it quite well. I would like to add that if your dispatch trigger vuex is not written in the current route and refresh the page, the data previously stored in vuex will be initialized and the data in vuex will be lost.
vuex stores the state, which represents the data corresponding to the view, and the storage location is in the memory;
Localstorage is an interface provided by the browser that allows you to save files and disks on your computer. Of course, you can also save the status locally!
They are completely two things. vuex is the state management mechanism in Vue, which facilitates communication between components; and localstorage is local storage, which is a method of storing data in the browser. It is generally used when transferring data across pages.
They are completely different things. Vuex is used for state management, which is the type of component data sharing. Data changes in one component will be mapped to other components that use this data. Let’s talk about localstorage, which is a simpler data storage method provided by H5. Previously, cookies were used to store data, but the amount of data stored in cookies was too small, and the interface was cumbersome. Localstorage data can have a limit of 5M, which is quite large, and the API is quite simple, easy to remember and easy to use. I believe it will become mainstream in the future.
xsf——1991 has already said it quite well. I would like to add that if your dispatch trigger vuex is not written in the current route and refresh the page, the data previously stored in vuex will be initialized and the data in vuex will be lost.