Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Strorage localized Storage in Vue

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "how to achieve Strorage localization storage in Vue". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to achieve Strorage localization storage in Vue" can help you solve your doubts.

Storage localized storage

Storage benefits:

More space: 4kb for cookie, 4kb for 5mb

Save network traffic: data will not be sent to the server and will be stored locally

Fast display: data stored locally + local cache in the browser, much faster than getting data from the server

LocalStorage

Session data is permanently stored unless manually deleted or removeItem

Data stored in all windows of the same origin is shared

Only data of string type can be stored. Complex object data must be processed with the help of stringfy and parse of JSON.

SessionStorage

Session data is stored during a session, and when the current session page (browser page) is closed, the data is deleted

Stored data cannot be shared across session windows

Only data of string type can be stored. Complex object data must be processed with the help of stringfy and parse of JSON.

For Strorage local storage instance, create a new storage.jsconst storage = {set (key,value) {sessionStorage.setItem (key,JSON.stringify (value));}, get (key) {return JSON.parse (sessionStorage.getItem (key));}, getForIndex (index) {return sessionStorage.key (index)}, getKeys () {let items = this.getAll (); let keys = []; for (let index = 0)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report