[英]Property 'confirmed' does not exist on type '{}'
我编写了一个函数来检查Cloud Firestore中的文档中是否存在一个字段来显示数据,如果不存在,则该字段不应显示数据。 它确实显示数据,但出现此错误error TS2339: Property 'confirmed' does not exist on type '{}'.
dataCollection: any;
data: Observable<MycollectionDoc[]>
activatedUsers: any[];
constructor(
private afs: AngularFirestore,
private router: Router
) { }
ngOnInit() {
this.activatedUsers = [];
let x = this.afs.collection('mycollection').valueChanges();
x.forEach(element => {
element.forEach(elem => {
console.log('My element', elem);
if (elem.confirmed) {
this.activatedUsers.push(elem);
console.log(elem)
}
})
});
}
Typescript不知道什么是type element
,因此会抱怨。
尝试将if (elem.confirmed)
替换为if (elem.hasOwnProperty('confirmed'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.