javascript - ngx-gallery 不显示图像
问题描述
我@ngx-gallery/lightbox
用来显示图片库。但它不显示任何图像。我提供了一些代码和Stackblitz演示作为您的参考
HTML
<button mat-button (click)="lightbox.open(0, 'lightbox')">Open Gallery</button>
零件
items: GalleryItem[];
constructor(public gallery: Gallery, public lightbox: Lightbox) {
}
ngOnInit() {
// This is for Basic example
this.items = imageData.map(item => {
return new ImageItem(item.srcUrl, item.previewUrl);
});
// This is for Lightbox example
this.gallery.ref('lightbox').load(this.items);
}
}
解决方案
问题是ImageItem
该类需要对象形式的单个参数。
这应该可以解决您的问题:
this.items = imageData.map(item => {
return new ImageItem({ src: item.srcUrl, thumb: item.previewUrl });
});
推荐阅读
- .htaccess - 用参数重写 url
- reactjs - 设置 Firebase 环境变量
- amazon-web-services - 如何捕获 CloudFormation 堆栈 CREATE_COMPLETED 事件并进行处理?
- rust - 如何合并不同的集合?
- oracle-apex - Oracle APEX 中的交互式网格 - 如果我选择“全选”,则只选择 40 行
- javascript - JavaScript中的getElementsByTagName方法---不起作用
- machine-learning - Gensim LDA 提供主题 ID 的输出,但概率加起来不等于 1
- react-leaflet - react-leaflet-control - TypeError: (0 , _reactLeaflet.withLeaflet) 不是函数
- reactjs - 获取 URL 缺少 OData 查询
- c# - 找出角度差异