属性 ID 在类型位置上不存在



我收到一个构建错误,如下所示:

app/app.component.ts(69,24): error TS2339: Property 'id' does not exist on type 'Location'

比我有一个函数updateDiv()看起来像这样:

updateDiv(location: Location, infoWindow:SebmGoogleMapInfoWindow) {
   this.selectedLocation = location;
   this.ID = location.id;
   this.content = location.content;
 }

这里是 html:

<sebm-google-map-overlay-view *ngFor="let location of locations" (markerClick)="updateDiv(location, infowindow)">

如何声明 id 和内容的属性?

属性"id"在类型"位置"上不存在

当你说一个函数接受类型Foo时,TypeScript 信任你(但你真的想说它的Bar)。如果您尝试像Bar一样使用它,则会收到这样的错误。你可能不是故意说Location 🌹

相关内容

最新更新