我正在尝试将一些数据保存在本地存储中。我的脚本如下所示:
localStorage.clear(); //only for testing
if(typeof localStorage.akten == "undefined") {
localStorage.akten = new Array();
}
var nam = "alpha";
localStorage.akten[nam] = {
"beta": 12
};
localStorage["a_akte"] = nam;
但如果我做console.log(localStorage);
或console.log(localStorage.akten);
akten
只是一个空字符串?为什么?使用普通对象而不是 localStorage 效果很好。