What is the difference between vuex and localstorage for storing data
怪我咯
怪我咯 2017-05-18 11:00:30
0
4
726

What is the difference between vuex and localstorage for storing data

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(4)
左手右手慢动作

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!

PHPzhong

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.

Peter_Zhu

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!