当前位置:网站首页>H5 local storage data sessionstorage, localstorage
H5 local storage data sessionstorage, localstorage
2022-04-23 07:45:00 【Senior salted fish~】
1、 characteristic :
(1) Convenient setting and reading
(2) Relatively large capacity ,sessionStorage about 5M,localStorage about 20M
(3) Only strings can be stored
(4)JASON Turn the string :JSON.stringify(json)
2、window.sessionStorage
(1) Life cycle : Close the browser , The data disappears
(2) Only on the current page ( Same window ) Data sharing
Example :
var data = {"name":" Xiao Chen ","age":19}
window.sessionStorage.setItem('data',JSON.stringify(data))
3、window.localStorage
(1) permanent , Unless you delete
(2) Under the same domain name and address Multi page shared data
Example :
var data1 = {"name":" Xiao Wang ","age":21}
window.localStorage.setItem('data1',JSON.stringify(data1))
Open other local html After checking the file, you can see the same data in the browser
4、 Method
(1)setItem(key,value) Set storage content
(2)getItem(key) Read the stored content
(3)removeItem(key) The delete key value is key Storage content of
(4)clear() Clear all stored content
版权声明
本文为[Senior salted fish~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230623086753.html
边栏推荐
猜你喜欢
SAP PI / Po rfc2restful Publishing RFC interface as restful examples (proxy indirect)
‘npm‘不是内部或外部命令,也不是可运行的程序 或批处理文件
How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
FSM finite state machine
Authorization+Token+JWT
js之排他思想及案例
Nacos / sentinel gateway current limiting and grouping (code)
Django uses MySQL database to solve error reporting
keytool: command not found
设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?
随机推荐
防抖和节流
12. Constraints
Implementation of MySQL persistence
SAP ECC连接SAP PI系统配置
每日一题 | 曾被反转链表支配的恐惧
BTree、B+Tree和HASH索引
8.分页查询
10.更新操作
【自我激励系列】到底是什么真正阻碍了你?
4. Multi table query
promise all的实现
对js中argumens的简单理解
MySQL storage engine
简易随机点名抽奖(js下编写)
系统与软件安全研究(三)
SAP Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃。
SAP DEBUG调试FOR IN、REDUCE等复杂的语句
2022.3.14 Ali written examination
int a = 1存放在哪
h5本地存储数据sessionStorage、localStorage