任何人都可以告訴我爲什麼這段代碼不會創建一個條目到localstorage嗎?試圖使用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: 'The Title', narrative: 'the Text' };
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), title: "The Title", narrative: "the Text"}
這是正確的格式,所以林不知道我做錯了什麼......
如果我更換myLocalStore.add(取值範) ;用myLocalStore.add('value');
的話,我會得到以下輸入到本地存儲
{"id":"ext-record-1","dateCreated":null,"title":null,"narrative":null}