【发布时间】:2017-09-15 12:11:15
【问题描述】:
我正在尝试在 HTML 中显示来自媒体 rss 提要的每个帖子的每个图像,而不使用 JQuery,而仅使用 javascript 或 Angular。 是否可以从 RSS 提要中获取图像?我收到了标题、创建日期和链接。 我正在使用 Ionic2。
entries: any = null;
image: any = null;
在我的构造函数中:
Feed.load('https://medium.com/feed/@jaymelone', (err, rss) => {
if (err) {
console.log(err);
}
else {
this.entries = rss.items;
this.image = this.entries.find('img').eq(0).attr('src');
}
console.log("RSS function - entries:", this.entries);
console.log("RSS function - image: ", this.image);
});
在我的 HTML 中
<div class="post" *ngFor="let entry of entries">
<div class="inner">
<img class="img" [src]="entry.image">
<p class="title">{{entry.title}}</p>
</div>
</div>
但我收到:
<img class="img" src="undefined">
还有:
TypeError: Array.prototype.find callback must be a function
【问题讨论】:
标签: javascript angularjs ionic2 rss medium-editor