thinkphp6 分页保留搜索条件
2022-07-28 14:14:58
163
{{single.collect_count}}

当数据过多时我们需要将所查询的数据进行分页处理
会碰到第一页数据可以显示出来 但是到第二页时就会变为空数据
thinkphp5跟thinkphp6所使用的方法不太一样
thinkphp5的

$data = Db::name('table')->paginate(3,false,['query'=>request()->param()]);

thinkphp6的

$data= Db::name('table')->paginate(['list_rows'=>2,'query' => request()->param()]);

这样既可保证我们的数据不会丢失
在进行搜索查询的时候可以保留参数

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}