繁体   English   中英

如何使用 ionic4 存储更新嵌套数组

[英]How can I update a nested array with ionic4 storage

使用

openSavedForm() {
  this.storage.get('test').then((val) => {
    this.auditResults = JSON.parse(val);
    this.audit = this.auditResults
    this.auditOne = this.auditResults.siteVehicle; 
    console.log('pull all', this.audit);     
  });
}

我可以在 sqlite 中查看我的键值对存储项。 这是 console.log 的照片

数据库的console.log

是否可以只更新 siteVehicle 数组

async saveFormUpdates() {
  this.newAudit =this.auditOne;
  await this.storage.set( 'test', JSON.stringify(this.newAudit));
  console.log ("storage", this.newAudit);
} 

不删除所有其他 arrays?

我的异步 saveFormUpdates() 是错误的。 结果只是保存 this.audit 而不是 this.auditOne 完成了所有操作,而我没有进一步的输入。

async saveFormUpdates() {
 this.newAudit = this.audit;
 await this.storage.set( 'test', JSON.stringify(this.newAudit));
 console.log ("storage", this.newAudit);
} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM