Sencha Touch 交流 QQ 群 224711028
localstorage将数据存在缓存中,使用最简单的用法有:
localStorage['aaa']='bbb';
alert(localStorage['aaa']);
此外可以建立model,定义proxy为‘localstorage’,通过载入到store后使用
Ext.regModel("Setting", {
fields: [
{name: "id", type: "int"},
{name: "query", type: "string"}
],
proxy: {
type: 'localstorage',
id : 'setting'
}
});
载入到store
Ext.regStore('Settings', {
model: 'Setting',
autoLoad: true
});
于是乎我们便可将store绑定到控件,读取当中的数据了。
当然存取的时候需要注意使用store中的create方法进行存取
Ext.getStore('Settings').create({query: 'aaa'});
删除的方法有
删除store中全部数据的:
Ext.getStore('Settings').removeAll();
还有就是删除指定序号的数据
store.removeAt(index);