我正在使用.snapshotChanges()
从Firestore提取数据。它有一个名为entryDate
的时间戳字段。导入数据时,我试图更改其格式。为此,我必须将timestamp
分配给变量,但会出错。下面是我的代码:
错误在这里:const timeinmillsecs = item.payload.entryDate.seconds * 1000; // error on this line
this.firestore.collection('projects' , ref => ref
.limit(10)
.orderBy('entryDate', 'desc')
)
.snapshotChanges()
.subscribe(response => {
if(!response.length){
console.log("no data available");
return false;
}
this.firstInResponse = response[0].payload.doc;
this.lastInResponse = response[response.length - 1].payload.doc;
console.log(this.firstInResponse);
console.log(this.lastInResponse);
this.tableData=[];
for(let item of response){
const timeinmillsecs = item.payload.entryDate.seconds * 1000; // error on this line
...
错误截图: