Vue2 - webStorage browser local storage

webStorage

  1. The storage content size generally supports about 5MB (different browsers may vary)

  1. The browser implements the local storage mechanism through the Window.session Storage and Window.local Storage properties.

  1. Related APIs:

  1. xxxxxStorage.setItem('key', 'value');

该方法接受一个键和值作为参数,会把键值对添加到存储中,如果键名存在,则更新其对应的值。
  1. xxxxxStorage.getItem('person');

This method accepts a key name as a parameter and returns the value corresponding to the key name.

  1. xxxxxStorage.removeItem('key');

This method accepts a key name as a parameter and deletes the key name from the storage.

  1. xxxxxStorage.clear()

This method clears all data in storage.

  1. Remark:

  1. The content stored in SessionStorage will disappear when the browser window is closed.

  1. The content stored in LocalStorage needs to be manually cleared before it disappears.

  1. xxxxxStorage.getItem(xxx) If the value corresponding to xxx cannot be obtained, the return value of getItem is null.

  1. The result of JSON.parse(null) is still null.

Guess you like

Origin blog.csdn.net/weixin_41606115/article/details/129034555