[HTML5]数组数据localStorage存储
保存数组数据
var itemsBak = [];
headerBar.items.each(function(value,index){
if(index > 2 && index < headerBar.items.length-1){
itemsBak.push({"iconCls":value.iconCls,"text":value.text,"id":value.id});
}
});
window.localStorage.setItem("headerBarValue",JSON.stringify(itemsBak));
console.log("快捷方式本地化存储: "+JSON.stringify(itemsBak));
读取本地存储数组数据
var items = [];
if(items = JSON.parse(window.localStorage.getItem("headerBarValue"))){
Ext.Array.each(items,function(value,index){
//console.log("初始化添加已有快捷方式:"+index+" -> "+value);
var page = {
iconCls: value["iconCls"],
cls: "headerStyle",
text: value["text"],
id: value["id"],
tooltip: value["text"],
iconAlign: "top",
handler: "onHeaderMenuClick"
};
Ext.getCmp("headerBar").insert(3,page);
});
}
【注】:以上示例是结合extjs6使用的情况!!!
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: C++程序员快速学习C#---(二)
- 下一篇: PHP中的for循环