渲染分页 renderPaginationcurrentPage totalPages var _this = this; layuiuselaypage function var laypage = layuilaypage; laypagerender elem pagination curr curre
,添加注释,使其更易读。
/**
- 渲染分页
- @param {number} currentPage 当前页数
- @param {number} totalPages 总页数 */ renderPagination(currentPage, totalPages) { // 保存this指向,方便后续使用 var _this = this; // 使用layui库中的laypage模块 layui.use(['laypage'], function() { var laypage = layui.laypage; // 渲染分页 laypage.render({ // 分页渲染的容器id elem: 'pagination', // 当前页数 curr: currentPage, // 分页跳转时的回调函数 jump: function(obj, first) { // 首次不执行 if (!first) { // 根据当前页数重新生成商品数据 _this.goodsList = _this.generateGoodsData(10); } } }); }); }
原文地址: https://www.cveoy.top/t/topic/bdtD 著作权归作者所有。请勿转载和采集!