我需要存储一个名为Projects的对象,该对象包含Teams,每个Team都包含用户,所有这些用户都没有表或其他sql东西,全部都存储在本地存储中,然后需要对它们和所有东西进行CRUD。有任何想法吗?
project = JSON.parse(localStorage.getItem('projects'));
console.log(project);
project.push(this.projectname);
localStorage.setItem("projects",JSON.stringify(project));
答案 0 :(得分:0)
您可以使用对象数组,如下所示:
var user1 = {"name":"user1"}; //Object1
var user2 = {"name":"user2"}; //Object2
var team = []; //array of objects
team.push(user1);
team.push(user2);
var projects = [];
projects.push(team);
console.log(projects); //store this into localstorage