我在我的视图中使用此代码作为滑块 但我想展示最后3个项目
<div class="flexslider">
<ul class="slides">
@foreach (var item in ViewBag.blog)
{
<li>
<a href="#">
<img src="@item.postImage" width="100%" alt="PostImage" style="margin-bottom: 10px;" />
<p class="flex-caption">@item.postTitle</p>
</a>
</li>
}
</ul>
</div>
答案 0 :(得分:1)
<div class="flexslider">
<ul class="slides">
@foreach (var item in ((List<your Model>)ViewBag.blog).Skip(((List<your Model>)ViewBag.list).Count-3))
{
<li>
<a href="#">
<img src="@item.postImage" width="100%" alt="PostImage" style="margin-bottom: 10px;" />
<p class="flex-caption">@item.postTitle</p>
</a>
</li>
}
</ul>
</div>