在控制中加入
use yii\data\Pagination;
public function page()
{
$query = 表名::find();
$pages = new Pagination([
//'totalCount' => $countQuery->count(),
'totalCount' => $query->count(),
'pageSize' => 5 //每页显示条数
]);
`$`models = $query->offset($pages->offset)
->limit($pages->limit)
->all();
return $this->render('list', [
'models' => $models,
'pages' => $pages
]);
}
在html页面加入
<?php use yii\widgets\LinkPager; ?>
<?= LinkPager::widget(['pagination' => $pagination]) ?>
yii2.0框架分页
最新推荐文章于 2019-08-15 12:26:18 发布