基本使用方法:
[Storage.key()
](https://developer.mozilla.org/en-US/docs/Web/API/Storage/key)
//When passed a number n, this method will return the name of the nth key in the storage.
[Storage.getItem()
](https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem)
//When passed a key name, will return that key's value.
[Storage.setItem()
](https://developer.mozilla.org/en-US/docs/Web/API/Storage/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.
[Storage.removeItem()
](https://developer.mozilla.org/en-US/docs/Web/API/Storage/removeItem)
//When passed a key name, will remove that key from the storage.
[Storage.clear()
](https://developer.mozilla.org/en-US/docs/Web/API/Storage/clear)
//When invoked, will empty all keys out of the storage.
其他:
- 只能存储字符串
- chrome 56下, 极限大小是5M左右.
- Safari无痕模式下设置localStorage会抛出异常.
网友评论