# WebStorage - 浏览器存储
# 1. 介绍
分类:
- localStorage
- sessionStorage
方法:
method | desc |
---|---|
key() | When passed a number n, this method will return the name of the nth key in the storage. |
getItem() | When passed a key name, will return that key's value. |
setItem() | When passed a key name and value, will add that key to the storage, or update that key's value if it already exists. |
removeItem() | When passed a key name, will remove that key from the storage. |
clear() | When invoked, will empty all keys out of the storage. |
# 2. sessionStorage
生命周期:
- 创建
- 打开页签
- 运行
- 销毁
- 关闭浏览器页签
- 关闭浏览器
注意:
- 每个页面(页签)都有独属自己的 sessionStorage, 互不干扰
# 3. 参考
上一篇: 下一篇:
本章目录