angular - 修改图像数组后,如何重新加载或刷新 ngx-gallery 缩略图?
问题描述
我正在使用ngx-gallery来显示图像。我想在修改订单时重新加载图像或在缩略图库、主图像和整页图像中刷新它们(例如交换图像数组中的图像 1 和 3)
问题- 我不知道如何重新加载/重置/重新渲染/刷新缩略图库。如果没有 ngx-gallery 的方式来做,也许有打字稿的方式?
这是我到目前为止尝试过的
<ngx-gallery #gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>
在我的 .ts 文件中
将图像设置为 null 然后替换图像:
this.galleryImages = null;
this.galleryImages = this.memberService.member.photos;
使用了文档中的 show(0) 方法 - 显示图像 0 但未在缩略图库中重新排列顺序
@ViewChild('gallery') 画廊:NgxGalleryComponent;
this.gallery.show(0);
我也试过
this.gallery.thubmnails.reset(1);
this.gallery.thubmnails.reset(0);
this.gallery.ngOnInit();
更新- 我在组件中找到了 thumbnail 属性,所以我可以更改缩略图的顺序,但仍然找不到更改主图像顺序的方法。
这是我更改缩略图排序的方法
[this.gallery.thubmnails.images[index], this.gallery.thubmnails.images[0]]
= [this.gallery.thubmnails.images[0], this.gallery.thubmnails.images[index]];
但这不会改变其他图像的顺序,当我尝试使用相同的方法时,它不适用于更大的(整页、页面)图像。
Update2我使用了一个间隔来提供解决方法并让它做我想做的事情。在我重新排序“this.memberService.member.photos”后,我清除了数组,然后用值重置它。没有间隔它不起作用。
[this.memberService.member.photos[index], this.memberService.member.photos[0]]
= [this.memberService.member.photos[0], this.memberService.member.photos[index]];
this.galleryImages = [];
setInterval(() => {
this.galleryImages = this.memberService.member.photos;
}, 0);
解决方案
推荐阅读
- bcpl - 在 BCPL 中,“of”是做什么的?
- python - Django 重定向不完整的 url
- python - 如何测量矢量的移动角度
- java - 如何使 clang-format 实际上破坏 Java 中的字符串文字?
- lua - 在 Pandoc 过滤器中嵌套额外的 Span 会使图像消失
- oauth-2.0 - 服务器使用 WSO2 身份服务器获取带有访问令牌的刷新令牌
- r - 使用 R 中的非线性最小二乘法优化参数值(带积分)
- sendgrid - SendGrid Incoming Parse WebHook 服务器的静态 IP 地址是什么?
- json - 在 Swift 5 中解析 JSON
- android - 与 Presenter 进行数据绑定