我无法将数据集添加到本地存储。我目前只能使用以下代码添加 1 个选项
const medicalPlansArr = medicalAidPlans[0].selectedMAP.map((x, index) => ({ label: x.options[index].optionName, value: x.options[index].id }));
localStorage.setItem('medicalPlans', JSON.stringify(medicalPlansArr));
这就是数据集的外观,我想要存储的唯一值是optionName和id
[
{
"selectedMAP": [
{
"mapName": "Default",
"options": [
{
id: 1,
optionName: 'Hospital Plan',
memberAmount: 1850,
adultDependantAmount: 900,
childDependantAmount: 900
},
{
id: 2,
optionName: 'Savings Plan',
memberAmount: 2200,
adultDependantAmount: 1100,
childDependantAmount: 1100
},
{
id: 3,
optionName: 'Elite Plan',
memberAmount: 4900,
adultDependantAmount: 2200,
childDependantAmount: 2200
}
]
}
]
}
];
任何想法为什么它不存储所有必需的值?
泛舟湖上清波郎朗
ABOUTYOU
胡说叔叔
随时随地看视频慕课网APP
相关分类