在layui学习的过程中,我做了数据表格,返回的时候也指定了count值,但是前端不显示分页
原因:前端使用动态渲染时 没有开启分页标志page;
前端渲染代码:
var tableIns = table.render({
elem: '#course',
page: true,//开启分页
url:'/student/courseList',
cols: [
[
{field:'courseName', title:'课程名称'},
{field:'collegeName', title:'学院名称'},
{field:'credits', title:'学分'},
{field:'startDate', title: '选修开始时间'},
{field:'endDate', title: '选修结束时间'},
{field:'optional', title: '可选人数'},
{field:'selected', title: '已选人数'},
{templet: complain, title: '课程详情', align:'center'},
{templet: complain2, title: '操作', align:'center'},
]
]
});
后端代码:
data={"code":0,"msg":"123","count":100,"data":[{'id':"1",'type':'0',"courseName":"数据库系统","collegeName":"计算机与信息学院",
"credits":"3","startDate":"2022-06-25 8:00","endDate":"2022-06-27 8:00","optional":255,"selected":24}
,{'id':"1",'type':'0',"courseName":"数据库系统","collegeName":"计算机与信息学院",
"credits":"3","startDate":"2022-06-25 8:00","endDate":"2022-06-27 8:00","optional":255,"selected":24}]}
data=json.dumps(data)
return data
运行图: