thinkphp8+layui分页

前端

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
  <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>
<table class="layui-table">
  <colgroup>
    <col width="150">
    <col width="150">
    <col>
  </colgroup>
  <thead>
  <tr>
    <th>ID</th>
    <th>realname</th>
    <th>gender</th>
  </tr>
  </thead>
  <tbody>
  {volist name="data" id="vo"}
  <tr>
    <td>{$vo.id}</td>
    <td>{$vo.realname}</td>
    <td>{$vo.sex}</td>
  </tr>
  {/volist}
  </tbody>
</table>
<div id="demo-laypage-all"></div>
<script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>
<script>
  layui.use(function(){
    const laypage = layui.laypage;
    // 完整显示
    laypage.render({
      elem: 'demo-laypage-all', // 元素 id
      theme: '#1E9FFF',
      count: 100, // 数据总数
      curr:{$page},
      layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
      jump: function(obj, first){
        console.log(obj);
        if(!first){
          window.location.href='?page='+obj.curr;
        }
      }
    });
  });
</script>
</body>
</html>

后端:

php 复制代码
public function index()
    {
        $page = input('get.page/d'); // 当前页码
        $result = Db::name('user')->paginate([
            'list_rows'=> 10,
            'page' => $page
        ]);
        return view('/index',['data'=>$result,'page'=>$page]);
    }
相关推荐
半个俗人13 分钟前
fiddler的基础使用
前端·测试工具·fiddler
a11177616 分钟前
变电站数字孪生大屏ThreeJS 开源项目
前端·信息可视化·开源·html
恋猫de小郭16 分钟前
AI 的公开测评得分都在作弊,就像泡面的封面,一切以实物为准
前端·人工智能·ai编程
禅思院18 分钟前
使用 VueUse 构建一个支持暂停/重置的 CountUp 组件
前端·vue.js·架构
薛定e的猫咪27 分钟前
2026 年 4 月实测:OpenAI Codex 保姆级教程,从安装到 MCP、Skills 与多智能体协作
前端·数据库·人工智能
I love studying!!!31 分钟前
Web应用程序:用户账户
前端·数据库·sqlite
whuhewei31 分钟前
React性能优化
前端·react.js·性能优化
m0_7381207232 分钟前
渗透知识ctfshow——Web应用安全与防护(三)
android·前端·安全
下北沢美食家42 分钟前
React面试题2
前端·react.js·前端框架
摇滚侠1 小时前
HTML CSS 演示小米 logo 的变化 border-radius 属性设置圆角
前端·css·html