localStorage的详细用法

朱明*

localStorage的详细用法

项目描述

localStorage的详细用法

上传时间

2021.06.27

浏览人数

862人
朱明*
天津市宁河县
Hot:16379

localStorage的特点

    1.localStorage将数据存储在本地,可以直接获取,减少了客户端和服务器端的交互。

    2.不参与和服务器的通讯,localStorage的值的类型限定为字符串类型。

    3.数据对象没有过期时间。

sessionStorage与localStorage的区别:

  1. localStorage属于永久性存储;sessionStorage属于临时性存储,存储的信息将随会话的结束而被清空。

  2. 同一浏览器中,相同的域名和端口下的不同页面中,localStorage的存储信息是可以共享的,sessionStorage的存储信息无法共享,仅适用于当前页面

<script type="text/javascript">

   /*1
   let i ={   用户信息
       name:"ss",
       job:"teacher"
   };

   console.log(i);
   i= JSON.stringify(i); //转化字符串
   console.log(i);//这样对应的key和值就投进去了

    手动的让某些数据缓存,长期缓存   只能投字符串类型
     localStorage.setItem("LOGIN_USER_INFO",i);
     */

   /*2 把缓存的值取出来

    let x = localStorage.getItem("LOGIN_USER_INFO");
     console.log(x);
     x = JSON.parse(x);//字符串转对象
     console.log(x.name);//只有是对象格式才能.某个值
      */

   /* 3  移除
   localStorage.setItem("aa","10001");
   localStorage.setItem("bb","10002");
   localStorage.setItem("cc","10003");

   localStorage.removeItem("aa");
       localStorage.clear("");
    */

   /* 4
   localStorage.setItem("aa","10001");
   localStorage.setItem("bb","10002");
   localStorage.setItem("cc","10003");

   let x = localStorage.key(0);//获取你想要的key
    console.log(x);

    let l = localStorage.length();//个数
     console.log(l);
             */

   /* 5
                 //参数hasOwnProperty有没有某个key
     let has = localStorage.hasOwnProperty("aa");
     console.log(has);
      */

   /*6 投入值
     sessionStorage.setItem("AAA","666");
          */
</script>


朱明*

当前作品暂无评分

还未获得评语哦~
python python培训 天津python培训 python培训班 python培训多少钱 Django 天津python培训班 天津python培训 天津python培训机构。天津python培训学什么? python python培训 天津python培训 Mysql django Numpy flask anaconda 天津python培训 天津python培训班 python培训 python 天津python培训 天津python培训班 数据爬虫 爬虫技术 python爬虫 python 天津python培训 python培训 python PyCharm Eclipse + 天津python培训 python培训 python PyCharm Eclipse + PyDev python培训 天津python培训 python培训班 python培训多少钱 PyCharm Eclipse + PyDev visual studio 天津python培训 天津python培训班 PyCharm Eclipse + PyDev visual studio 天津python培训 天津python培训班 天津python培训机构 python培训班 C/C++ Java Python 天津python培训 天津python培训班 天津python培训机构 python培训班 C/C++ Java Python 天津python培训 天津python培训班 天津python培训机构 python培训班 C/C++ Java Python 天津python培训 天津python培训班 天津python培训机构 python培训班 C/C++ Java Python 天津python培训 天津python培训班 天津python培训机构 python培训班 python java web 天津python培训 天津python培训哪家好 天津python培训机构 天津python培训班 python java web前端 天津python培训 天津python培训班 天津python培训机构 天津python培训学校 python java web 天津python培训 天津python培训班 天津python培训机构 python培训 python java web 天津python培训 天津python培训班 天津python培训机构 天津python培训学校 python java web 天津python培训 天津python培训班 天津python培训机构 python java web 天津python培训 天津python培训班 天津python培训机构 天津python培训学校 python Java web 天津python培训 天津python培训学校 天津python培训机构 天津python培训班 python java web 天津python培训 天津python培训班 天津python培训机构 python培训 python Java web 天津python培训 天津python培训机构 天津python培训班 python培训 python java web 天津python培训 天津python培训机构 天津python培训学校 python培训 python java web 天津python培训 天津python培训班 天津python培训机构 python培训 python java web 天津python培训 天津python培训班 天津python培训机构 python培训 python java web 天津python培训 天津python培训班 天津python培训机构 python培训学校 python java web 天津python培训 天津python培训机构 python培训班 python java web 天津Java培训 天津Java培训班 Java培训 天津Java培训机构 python web java 天津python培训 天津python培训班 天津python培训机构 python java web 天津python培训 天津python培训班 python培训 天津python培训机构 python java web 天津python培训 天津python培训班 天津python培训机构 python培训 python web java 天津python培训 天津python培训班 python培训 python web java 天津python培训 天津python培训班 python培训 python web java 天津python培训 天津python培训机构 天津python培训学校 python web java 天津python培训班 天津python培训机构 天津python培训学校 python java web 天津python培训 天津python培训机构 python培训 python web java 天津python培训 天津python培训班 python培训 python web java 天津python培训 天津python培训机构 python培训 python web java 天津python培训 天津python培训班 python培训 python web java 天津python培训 天津python培训班
朱明*    16379 天津市宁河县 设计师杨冰是女孩 1996.**.**
本网站已在中国版权保护中心登记了美术作品著作权与软件著作权违者将依法追究责任,特此声明! | Copyright©2013-2022,zhuzuoji.com | 诚筑说培训学校(天津)有限公司内容支持 | 京ICP备17020986号-5