我正在尝试学习 javascript,并且正在尝试找出项目的本地存储。但首先我相信我需要从我的团队构造函数中以编程方式构建密钥。
var Team = function(team, manager, cell, add1, add2, city, st, zip, sponsor) {
this.team = team;
this.manager = manager;
this.cell = cell;
this.add1 = add1;
this.add2 = add2;
this.city = city;
this.st = st;
this.zip = zip;
this.sponsor = sponsor;
};
这是来自我构建的表单,现在我想构建本地存储。这是我失败的尝试:
function saveTeam() {
for (var i = 0; i < Team.length; i++) {
localStorage["league." + i "." + javascriptNameOfProperty ] = $('#'+ javascriptNameOfPropertyName + ').val() };
或类似的东西。我试过“property”、“key”和我试过的其他方法不适用于 javascriptNameofProperty。当然,一旦我弄清楚了,我当然必须弄清楚本地存储。