doT.js模板和pagination分页应用
博客中模拟了数据加载初始化的过程。
doT.js渲染每一项内容的数据项。示例如下:
<script id="Messtmpl" type="text/x-dot-template">
{{~it.bean:value:index }}
<div class="MessListItem {{?value.read}}on{{?}}" mid="{{=value.id}}">
<strong>{{=value.title}}</strong>
<div class="words cls">
<p>{{=value.message}}</p>
<label>{{=value.time}}</label>
</div>
<a class="closed">X</a>
</div>
{{~}}
</script>
pagination分页插件的使用,示例如下:
MessPage.pagination(total, {
callback: initPage,
prev_text: "«",
next_text: "»",
items_per_page: pageSide,
num_edge_entries: 1,
num_display_entries: 10,
current_page: current
});
参数说明:
callback:回调方法,点击分页按钮的时候执行。
prev_text:上一页按钮中的文字显示内容。
next_text:下一页按钮中的文字显示内容。
items_per_page: 每一页中显示的条数。
num_edge_entries:首尾两侧分页的条数。
num_display_entries:分页主体显示的条数。
current_page:: 当前页数。
DEMO:
来源:https://www.cnblogs.com/kuikui/p/3562552.html