我正在使用 Lawnchair 将数据保存在 js 中并将其检索回用于我的移动应用程序。
我的 js 文件中有这个。
$(document).ready(function() {
//Lawchair set up
db = Lawnchair({name: 'db'},function(e){
console.log('storage open');
});
//store the 'username' key in storage
db.save({key:"username", value: "john"});
var name = ""
db.get("username", function(obj){
name = obj.value;
})
alert(name);
});
问题是我总是在名字中得到“”。我永远不能在 Lawnchair 对象的“get”回调函数中设置任何变量。我错过了什么吗?
任何帮助,将不胜感激。
谢谢。