javascript LocalStorage Basic Useg

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript LocalStorage Basic Useg相关的知识,希望对你有一定的参考价值。

let header = document.getElementsByTagName("h1")[0];
let siteData = {
  siteName: "My Site",
  siteDescription: "Another JS Site"
};
let localData;

localStorage.setItem("siteDataLS", JSON.stringify(siteData));

localData = JSON.parse(localStorage.getItem("siteDataLS"));


// Ovim putem localData === siteData , pa kad pozivamo npr siteName krecemo sam localData.siteName --- My Site
let h1 = document.getElementById("header").innerHTML = localData.siteName;

// Brisanje svega iz localStorage-a
//localStorage.removeItem("siteDataLS");

以上是关于javascript LocalStorage Basic Useg的主要内容,如果未能解决你的问题,请参考以下文章

如何从 Backbone.LocalStorage 获取 Backbone.Collection

[JavaScript]localStorage对象

javascript localStorage对象#js #localstorage

javascript localStorage对象#js #localstorage

javaScript --- localStorage 本地存储

HTML5 localStorage 有用的函数 // JavaScript,TypeScript [关闭]