我正在编写一个Ionic应用程序,它通过使用“存储”来存储一些表单条目和一些选项。现在我想计算选项,但我总是得到零。
下面的代码是:
async getAllEntries()
{
let count = 0;
this.trackingEntries = [];
this.storage.forEach((value, key, index) =>
{
if (key != "Options0" && key != "Options1" && key != "Options2" && key != "Options3" )
{
this.trackingEntries.push(value);
count++;
}
})
console.log(this.trackingEntries);
console.log("Count: " + count);
}
console.log(this.trackingEntries)会传回下列对象:
[
{
"timestamp": "1663677073",
"tracking": [
"6",
"4",
"5",
"6"
]
},
{
"timestamp": "1663677073",
"tracking": [
"2",
"2",
"2",
"2"
]
},
{
"timestamp": "1663677073",
"tracking": [
"2",
"2",
"2",
"2"
]
}
]
但是计数变量总是零,我该怎么解决这个问题呢?
1条答案
按热度按时间0dxa2lsx1#
我用“那么”找到了解决办法。
}