抱歉,如果格式错误或问题愚蠢,我是新手。我使用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>
将最后一个 ko 改为 if: to
<!-- ko if: $index() === $parent.PropertyDetails().Images().length - 1 -->
成功了,以防万一其他人遇到这个问题:)