如何将这个索引数组names
添加到localStorage
。并调用这个元素:
var name= new Array();
for( var i=0; i<results.rows.length; i++ ) {
names[results.rows.item(i).IdTypePrestation ] = results.rows.item(i).LibellePrestation;
}
如果我更改此行:
names[results.rows.item(i).IdTypePrestation] = results.rows.item(i).LibellePrestation;
对此:
names[i] = results.rows.item(i).LibellePrestation;
一切都很好,但我需要第一行。
最佳答案
设置为本地存储
:
localStorage.someArrayValue = JSON.stringify(myArray);
从localStorage
获取:
myArray = JSON.parse(localStorage.someArrayValue);
关于javascript - 将索引数组添加到 localStorage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13936667/