尝试使用Sencha Touch 2.1.1将值传递到本地存储 [英] Trying to pass values to local storage using Sencha Touch 2.1.1
问题描述
myLocalStore.load()可以让任何人告诉我为什么这一段代码不会创建一个本地存储的条目? ;
var now = new Date();
var cardId =(now.getTime())。toString()+(this.getRandomInt(0,100))。toString();
var entry1 = {id:cardId,dateCreated:now,title:'标题',叙述:'文本'};
var newRecord = new PinYin.model.Default(entry1);
myLocalStore.add(newRecord);
myLocalStore.sync();
console.log(entry1);
控制台输出
Object {id:136575772251069,dateCreated:Fri Apr 12 2013 17:08:42 GMT + 0800(Taipei Standard Time),标题:The Title,叙述:the Text}
这是正确的格式,所以我不知道我在做错什么...
如果我替换myLocalStore.add(entry1);与myLocalStore.add('value');
然后我会得到以下输入到本地存储
{ ID: EXT-记录-1, dateCreated会:NULL, 标题:空, 叙述:空}
尝试这样...
var airline_name = res [i] .AirLineName;
localStorage.setItem(AirlineCode3two,record.get('AirlineCode32'));
var stored_locally2 = {'ID2':i,'AirLineName2':res [i] .AirLineName,};
//将我们的数组添加到LocalStore(localStorage)
var localstore2 = Ext.getStore('TwowayStorage');
var twowayc1 = localstore2.getCount();
localstore2.add(stored_locally2);
localstore2.sync();
localstore2.load();
Can anyone tell me why this bit of code doesn't create an entry into localstorage?
myLocalStore.load();
var now = new Date();
var cardId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString();
var entry1 = { id: cardId, dateCreated: now, title: 'The Title', narrative: 'the Text' };
var newRecord = new PinYin.model.Default(entry1);
myLocalStore.add(newRecord);
myLocalStore.sync();
console.log(entry1);
The console outputs
Object{id: "136575772251069", dateCreated: Fri Apr 12 2013 17:08:42 GMT+0800 (Taipei Standard Time), title: "The Title", narrative: "the Text"}
which is the correct format so im not sure what I'm doing wrong...
if I replace myLocalStore.add(entry1); with myLocalStore.add('value');
then i'll get the following inputted into the local storage
{"id":"ext-record-1","dateCreated":null,"title":null,"narrative":null}
Try like this...
var airline_name = res[i].AirLineName;
localStorage.setItem("AirlineCode3two",record.get('AirlineCode32'));
var stored_locally2 = {'ID2': i,'AirLineName2': res[i].AirLineName,};
//Adding our array to LocalStore(localStorage)
var localstore2 = Ext.getStore('TwowayStorage');
var twowayc1=localstore2.getCount();
localstore2.add(stored_locally2);
localstore2.sync();
localstore2.load();
这篇关于尝试使用Sencha Touch 2.1.1将值传递到本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!