thinkphp5分页样式

分享 已结 3 2325
zhiqiang
zhiqiang VIP3 2017-8-28
悬赏:5飞吻
thinkphp5控制器写法
    function index($keyword='', $page = 1){
$map = [];
if ($keyword) {
$map['code'] = ['like', "%{$keyword}%"];
}
$list=Db('package')->where($map)->paginate(10, false, ['page' => $page]);
return $this->fetch('index',['list'=>$list,'keyword'=>$keyword]);
}
模板写法
/*循环输出数据*/ 
{foreach $list as $vo}
id {$vo.code}
{/foreach}
/*分页写法*/
{$list->render()}
分页样式
<style>
/*分页*/
.pagination {}
.pagination li {display: inline-block;margin-right: -1px;padding: 5px;border: 1px solid #e2e2e2;min-width: 20px;text-align: center;}
.pagination li.active {background: #009688;color: #fff;border: 1px solid #009688;}
.pagination li a {display: block;text-align: center;}
</style>
回帖
本帖已设置禁止回复