mingyunyuziyou

thinlphp5 分页 ajax 无刷新

作者: 秒速五厘米     
 



<?php
namespace app\index\controller;

use think\Controller;
use think\Db;

class Index extends Controller
{
    public function index()
    {
        $data=Db::name('user')->where('id','>',1)->paginate(10);
        $this->assign('list',$data);
        return $this->fetch('index');
    }

    public function ajax(){
        return $this->fetch('');
    }

}
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
 content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        ul li{
            list-style:none;
        }
        .pagination li{
            display: inline;
            padding: 10px;
        }
    </style>
</head>
<body>
<div>
    <ul>
        {volist name='list' id='user'}
        <li> {$user.name}</li>
        {/volist}
    </ul>
</div>
</body>



</html>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
 content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        ul li{
            list-style:none;
        }
        .pagination li{
            display: inline;
            padding: 10px;
        }
    </style>
</head>
<body>
<div>
    <ul>
        {volist name='list' id='user'}
        <li> {$user.name}</li>
        {/volist}
    </ul>
</div>
</body>



</html>