gpt4 book ai didi

javascript - 将索引数组添加到 localStorage

转载 作者:行者123 更新时间:2023-11-28 09:29:03 24 4
gpt4 key购买 nike

如何将这个索引数组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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com