在页面js table.render()写入代码如下
parseData: function (res) {
// console.log(res.data.current_page);
return {
"code": res.code,
// "msg": res.msg,
"data": res.data,
"count": res.count
};
}
服务端代码
$page=$request->input('page');
$limit=$request->input('limit');
$offset = ($page - 1) * $limit;
$num=DB::table('order')->count();
$info=DB::table('order') ->offset($offset)->paginate($limit);
$data=$info->toArray();
return json_encode(['code'=>0,'count'=>$num,'data'=>$data]);
注意返回格式