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]);
    }
相关推荐
风骏时光牛马1 分钟前
AI_Coding:智能代码生成与工程实践
前端
颜进强6 分钟前
22 · NestJs InjectionScopes 注入作用域:默认单例不是偷懒,是最优——以及何时才该打破
前端·后端·ai编程
liangshanbo121515 分钟前
Web Worker 在 AI 前端应用中有什么具体使用场景?
前端·人工智能
拖孩32 分钟前
一个全程 AI 写的小程序「厨菜记」,上线 20 天跑通流量主,收入几块钱,开心得不行
前端·后端·微信小程序
颜进强34 分钟前
21 · NestJs AsyncProviders 异步提供者:useFactory 返回 Promise 之后,容器发生了什么
前端·后端·ai编程
莪_幻尘1 小时前
Agent 体检:乱编、连锁、失忆,给 Agent 做一次五维体检
前端·人工智能·agent
秋天的一阵风1 小时前
🚀 nacos-web-config:运营半夜改条配置,网页秒更新 —— 不用发版、不用轮询,我把它开源了
java·前端·开源
不一样的少年_1 小时前
别用前端思维写后端:一张 5MB 图片,为什么能撑爆内存?
前端·后端·图片资源
沐言人生1 小时前
太吊了!这 2 款网盘工具,让我省 4000 大洋!
前端
鬼手点金1 小时前
opencode-隐私优先配置
服务器·前端·javascript·bug·openclaw