thinkphp3.2.3+laypage+ajax分页

新建一个分页控制器

PageController.class.php

代码如下

<?php


namespace Home\Controller;


use Think\Controller;

class PageController extends Controller{
   public function index(){
       // 获取当前页码,默认第一页,设置每页默认显示条数
       $nowpage = I('get.page', 1, 'intval');
       $limits = 8;
       // 获取总条数
       $count = M('Address') -> count();
       // 计算总页面
       $allpage = ceil($count / $limits);
       $allpage = intval($allpage);

       $lists = M('Address')
           -> page($nowpage, $limits)  // page 方法分页
           -> order('id asc')
           -> select();

       // 跳转分页输出
     /*  $this -> assign('lists', $lists);
       $this -> assign('allpage', $allpage);
       $this -> assign('nowpage', $nowpage);
       $this->display();*/


       // ajax 分页输出
       $info = array('lists'=>$lists,'allpage'=>$allpage,'nowpage'=>$nowpage);
       $this->ajaxReturn($info,'json');

   }

   public function test(){
       $this->display('index');
   }
}

page/index.html页面代码

layPage demo{
            : : }
        {
            : }
        {
            : : : : : : }
        {

        }
    {$vo.id}:{$vo.name}(curr){
        .({
            : curr }(res){ view = .()li = list = res..(list(indexarray){ li += +array.+})view.= li({
                : : res.allpage: res.nowpage: : : (objfirst){ (!first){ (obj.)}
                }
            })})}()

uploads_2016-07-11_57837dec39840.jpg

雷亮博客
请先登陆后发表评论
  • 最新评论
  • 总共0条评论
  • 本站使用thinkphp搭建 © 2014-2016 blog.wo97.com 版权所有 ICP证:蜀ICP备16024789号
  • 工信部
  • 联系邮箱:1031041088@qq.com