I am using @ngx-gallery/lightbox
to display an image gallery. But it does not display any images. This I provide some code and Stackblitz demo as your reference
的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);
}
}
I'm not sure what api u were reading from, but according to their official api, this demo should work
The issue is that the
ImageItem
class expects a single parameter in form of an object.这应该可以解决您的问题:
似乎您尚未正确初始化ImageItem,请尝试此操作
代替