knockout.js 使用数组中的最后一个图像

u0sqgete  于 7个月前  发布在  其他
关注(0)|答案(1)|浏览(76)

抱歉,如果错误的格式或愚蠢的问题,我是新来的。我使用knockout js,通常用它来找到一个有索引的图像并显示它,然而,我想知道是否有可能确保它是最后一个图像,无论索引号如何,下面是我目前使用的代码示例。

<div style="position: absolute; right: 0px; bottom: 0px">
    <!-- ko foreach: PropertyDetails().Images() -->
    <!-- ko if: DocumentSubType().SystemName() === "Photo" -->
    <!-- ko if: $index() === 7 -->
    <div
      data-bind="attr:{id: 'picture-' + Id() }, widget: {
                kind: 'ImageManipulator',
                config: {
                    width: '546px',
                    height: '380px',
                    imageUrl: Url().indexOf('http://www.example.com/estate-agent-software/ImageResizeHandler.do') == -1 ? Url() + '?width=NaN' : Url() + '&width=NaN'
                },
                identification: {
                    Id: 'property-image-' + Id()
                }}"
    ></div>
    <!--/ko-->
    <!--/ko-->
    <!--/ko-->
  </div>
hgtggwj0

hgtggwj01#

改变最后一个ko,如果:到

<!-- ko if: $index() === $parent.PropertyDetails().Images().length - 1 -->

做了这个把戏,以防万一其他人遇到这个问题:)

相关问题