Correction status:qualified
Teacher's comments:
controller index.php <?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index() { $curr = max(1,(int)input('get.page')); $this->view->assign('data',$curr); return $this->view->fetch(); } } view index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>hello</title> <link rel="stylesheet" href="/static/layui/css/layui.css"> <script src="/static/layui/layui.js"></script> </head> <body> <form action=""> <div> <label>选择框</label> <div> <select name="interest" lay-filter="aihao"> <option value=""></option> <option value="0">写作</option> <option value="1">阅读</option> <option value="2">游戏</option> <option value="3">音乐</option> <option value="4">旅行</option> </select> </div> </div> </form> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;"> <legend>自定义排版</legend> </fieldset> ====== {$data} ==== <div id="demo8"></div> </body> </html> <script> layui.use(['form','laypage','layer'],function(){ var form = layui.form; var laypage = layui.laypage; var layer = layui.layer; //自定义排版 laypage.render({ elem: 'demo8' ,count: 100 ,curr: {$data} ,layout: ['limit', 'prev', 'page', 'next'] ,jump: function(obj, first){ //obj包含了当前分页的所有参数,比如: // console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。 // console.log(obj.limit); //得到每页显示的条数 //首次不执行 if(!first){ console.log(obj.curr); window.location.href = '?page='+obj.curr; //do something } } }); }) </script>