Skip to content

Commit

Permalink
fix(ImageViewer): 修复images长度更新导致index显示异常 (#3111)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmywang authored Sep 3, 2024
1 parent 4c112f8 commit b4293d7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/image-viewer/image-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export default class ImageViewer extends SuperComponent {
}

observers = {
visible(value) {
this.setData({
currentSwiperIndex: value ? this.properties.initialIndex : 0,
});
'visible,initialIndex,images'(visible, initialIndex, images) {
if (visible && images?.length) {
this.setData({
currentSwiperIndex: initialIndex >= images.length ? images.length - 1 : initialIndex,
});
}
},

closeBtn(v) {
Expand Down

0 comments on commit b4293d7

Please sign in to comment.