一.定义json
var employees = [
{ "firstName":"Bill" , "lastName":"Gates" },
{ "firstName":"George" , "lastName":"Bush" },
{ "firstName":"Thomas" , "lastName": "Carter" }
];
保存数据到本地

const info = {
name: 'Lee',
age: 20,
id: '001'
};
sessionStorage.setItem('key', JSON.stringify(info));
localStorage.setItem('key', JSON.stringify(info));
本地存储中删除某个保存的数据

sessionStorage.removeItem('key');
localStorage.removeItem('key');
删除所有保存的数据

sessionStorage.clear();
localStorage.clear();
删除对象

object.splice(index,1);
localStorage.setItem("GouWuChe",JSON.stringify(object));

相关文章:

  • 2022-01-09
  • 2022-01-11
  • 2021-04-15
  • 2021-12-29
  • 2021-07-18
  • 2021-06-14
  • 2022-02-09
猜你喜欢
  • 2021-06-23
  • 2021-11-05
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-03
相关资源
相似解决方案