概述:ThinkPHP6分页时使用paginate(['list_rows'=>2,'query'=>request()->param()])函数地址栏出现%2Fsearch_html=的解决方法
解决方法:
1、代码中加入 dump(request()->param()) 打印结果
array:3 [
"/search_html" => ""
"keyword" => "www.pcxpcx.com"
"page" => "2"
]
因此得知是因为request()->param()多出了/search_html
2、将数组中/search_html去掉
$query_temp = request()->param();
$query = array_splice($query_temp, 1, 2);
$list = Db::name('articles')
->where('title','like','%'.$keyword.'%')
->order('id','desc')
->paginate(['list_rows'=>20,'query'=>$query]);
原创不易,转载请保留本站版权。