一、sessionStorage: 浏览关闭会话结束就被清除;(不能跨页面)

  localStorage:永久保存;

二、使用

var storage = window.sessionStorage;

storage["key"] = "123";//赋值
alert(storage["key"] );//取值

storage.removeItem("key");//清除缓存
storage.clear();//清除所有缓存

//localStorage使用方法类同

三、参考:

https://my.oschina.net/adamboy/blog/74162

http://www.w3school.com.cn/html5/html_5_webstorage.asp

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2021-11-27
  • 2021-05-24
相关资源
相似解决方案