我正在尝试映射从Cloud Firestore集合传入的数据,并尝试调用传入的特定类型的密钥。相反,它在我的IDE中吐出了Property 'desc' does not exist on type 'unknown'.ts(2339)
。发生这种情况的任何原因?
descArray;
idArray;
buses = [];
...
.subscribe(res => {
console.log(res)
this.descArray = res.map(thisbus => thisbus.payload.doc.data().desc);
console.log(this.descArray);
this.idArray = res.map(thisbus => thisbus.payload.doc.data().UID);
console.log(this.idArray);
for(let i in this.descArray) {
console.log(this.descArray[i])
console.log(this.idArray[i])
this.buses.push({
id: this.idArray[i],
desc: this.descArray[i]
})
}
编辑:我在调试器行中输入了console.log(thisbus.payload.doc.data())
并返回了此代码:
{UID: "001", desc: "Bus 33", lat: 47.522775, long: -121.82}
UID: "001"
desc: "Bus 33"
lat: 47.522775
long: -121.82
__proto__:
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ ()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()