先说怎么用,用在哪儿。
localStorage
-
设置
- localStorage.setItem(key,value)
- localStorage.name = "kane"
-
删除
- localStorage.clear() 删除所有
- localStorage.removeItem("name")删除指定
-
查询
- localStorage.getItem(key)
- localStorage[key]
- localStorage.valueOf() 查询所有
- localStorage.hasOwnProperty(key)是否包含
- localStorage.key(num=0) 查询index,默认查询第一个key
网友评论