1 回答
TA贡献1777条经验 获得超3个赞
我认为你的 jsonstuffs 需要是一个像这样的对象:
var jsonstuffs = {
setData: function (key, obj) {
var values = JSON.stringify(obj);
localStorage.setItem(key, values);
},
getData: function (key) {
if (localStorage.getItem(key) != null) {
return JSON.parse(localStorage.getItem(key));
} else {
return false;
}
},
updateDate: function (key, newData) {
if (localStorage.getItem(key) != null) {
var oldData = JSON.parse(localStorage.getItem(key));
for (keyObj in newData) {
oldData[keyObj] = newData[keyObj];
}
var values = JSON.stringify(oldData);
localStorage.setItem(key, values);
} else {
return false;
}
}
}
- 1 回答
- 0 关注
- 78 浏览
添加回答
举报