我正在使用CLI命令:$ ng build --prod构建一个Angular项目,并收到以下错误:
ERROR in src/app/fetch-api/fetch-api.component.html(5,7): : Property 'featured' does not exist on type 'string[]'.我的html代码是:
<ul>
<li *ngFor="let fetch of fetchApi.data.featured">
<ul>
<li><b> {{fetch.description.split('|')[0]}}</b></li>
<li><youtube-player
content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *;"
[videoId]="fetch.video_id_" (ready)="savePlayer($event)"
(change)="onStateChange($event)"></youtube-player> <!-- <iframe width="560" height="315" [src]="myFunction(fetch.video_location)" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
--></li>
</ul>
</li>
</ul>我的代码有什么问题?
发布于 2018-06-13 15:18:33
首先,你遇到的问题是Angular而不是AngularJS。
您的代码的问题正是错误消息所说的。fetchApi.data是没有featured属性的字符串数组。
您为fetchApi.data.featured定义了错误的类型。在component.ts文件中检查该对象的类型声明。
https://stackoverflow.com/questions/50831065
复制相似问题