【发布时间】:2018-11-13 22:17:56
【问题描述】:
我已经在论坛中寻找了一段时间,但无法正常工作。
基本上我使用设置我的数据
this.storage.set('data', [
{id:1, name: 'a'}, {id: 2, name:'b'}
])
如何在不覆盖数组的情况下编辑 id:2 的名称?我做了一些获取和设置,但最终覆盖了整个对象。
我在这里尝试了其中一种解决方案,但最终覆盖了对象
// Get the entire data
this.storage.get('data').then(valueStr => {
let value = valueStr[1];
// Modify just that property
value.name = "hello";
// Save the entire data again
this.storage.set('pets', JSON.stringify(value));
console.log(valueStr)
});
希望我能得到一些帮助。谢谢。
【问题讨论】:
标签: ionic-framework ionic2 ionic3