本地存储 电脑版发表于:2020/4/27 11:05 存储读取 ``` // 存储 localStorage.setItem("lastname", "Gates"); // 取回 document.getElementById("result").innerHTML = localStorage.getItem("lastname"); ``` 遍历: ``` //遍历本地存储localStorage for (var i = 0; i < localStorage.length; i++) { var key = localStorage.key(i); //获取本地存储的Key console.log(key); console.log(localStorage.getItem(key));//所有value console.log("---------------------------------"); } ```