第一步:下载Page.class.php

把下载后的Page.class.php放入ThinkPHP/Extend/Library/ORG/Util/(如果该目录不存在就手动去创建)。

第二步:控制器

 

  $User = M('Goods');//实例化Goods数据对象  Goods是你的表名
  //p是前台传值过来的参数,也就是页码
    if($_GET['p']==NULL){
        $p=1;
    }else{
        $p=$_GET['p'];
    }
    $list = $User->order('id')->page($p.',10')->select();// 查询满足要求的总记录数
    $this->assign('list',$list);// 赋值数据集
    $count = $User->count();
    $Page = new \Think\Page($count,10);
    $show = $Page->show();
    $this->assign('page',$show);
    $this->display();

第三步:视图

<div class="result page">{$page}</div>

第四步:css

引入的样式小编感觉不是很好看,所以进行了一下美化,想要的童鞋可以拿走哦

.page{
    padding-top: 20px;
    padding-bottom: 15px;
    text-align: center;
    clear: both;
}
.num,.current,.prev,.next{
background-color: rgb(255, 255, 255);
border-bottom-color: rgb(226, 226, 226);
border-bottom-style: solid;
border-bottom-width: 0.666667px;
border-image-outset: 0;
border-image-repeat: stretch stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgb(226, 226, 226);
border-left-style: solid;
border-left-width: 0.666667px;
border-right-color: rgb(226, 226, 226);
border-right-style: solid;
border-right-width: 0.666667px;
border-top-color: rgb(226, 226, 226);
border-top-style: solid;
border-top-width: 0.666667px;
box-sizing: content-box;
color: rgb(51, 51, 51);
display: inline-block;
font-family: Helvetica Neue, Helvetica, PingFang SC, 微软雅黑, Tahoma, Arial, sans-serif;
font-feature-settings: normal;
font-kerning: auto;
font-language-override: normal;
font-size: 12px;
font-size-adjust: none;
font-stretch: normal;
font-style: normal;
font-variant: normal;
font-variant-alternates: normal;
font-variant-caps: normal;
font-variant-east-asian: normal;
font-variant-ligatures: normal;
font-variant-numeric: normal;
font-variant-position: normal;
font-weight: 400;
height: 28px;
line-height: 28px;
margin-bottom: 5px;
margin-left: 0px;
margin-right: -1px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 15px;
padding-right: 15px;
padding-top: 0px;
position: relative;
text-align: left;
vertical-align: middle;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
}
.current{
    background:orange;
}

Last modification:October 16, 2018
If you think my article is useful to you, please feel free to appreciate