1.使用Nuget下载LazZiya.TagHelpers
2._ViewImports.cshtml中添加
@addTagHelper *, LazZiya.TagHelpers
3.前台页面使用
<table class="table table-bordered"> <thead> <tr> <th> 商品名 </th> <th> 价格 </th> </tr> </thead> <tbody> @foreach (var item in Model.RakutenGoodsRankingList) { <tr> <td> @item.GoodsName</td> <td> @item.GoodsPrice</td> </tr> } </tbody> <tfoot> </tfoot> </table> <nav> <paging class="pagination" page-no="Model.PageNo" page-size="Model.PageSize" total-records="Model.TotalRecords" render-mode="Bootstrap5"> </paging> </nav>
render-mode的参数说明:
Classic :regular dropdown list
Bootstrap :HTML5 div with Bootstrap 4 support
FormControl :Render as form control
Bootstrap5 :HTML5 div with Bootstrap 5 support
注意,
1.官方提供的参数不是很全,可能很久没更新了。
2.部分参数如果不清楚属性的话,可以自行看源码。
例如render-mode,在源码中,其实是需要搜索rendermode关键词,也就是去掉横线的词。
4.后台页面使用
public List<RakutenGoodsRanking> RakutenGoodsRankingList { get; set; } public int PageNo { get; set; } public int PageSize { get; set; } public int TotalRecords { get; set; } public void OnGet(int p = 1, int s = 3) { RakutenGoodsRankingList = _memberTrackManageContext.RakutenGoodsRankings.Where(r => r.DataTypeName == "CD").OrderByDescending(r => r.DeliveryDate).Skip((p - 1) * s).Take(s).ToList(); PageSize = s; TotalRecords = _memberTrackManageContext.RakutenGoodsRankings.Where(r => r.DataTypeName == "CD").Count(); PageNo = p; }
5.效果如图
标签:core,asp,Razor,get,int,item,set,RakutenGoodsRankingList,public From: https://www.cnblogs.com/shihao316558512/p/16720327.html