Thinkphp5分頁(yè)后攜帶參數(shù)跳轉(zhuǎn)傳遞功能實(shí)現(xiàn)
我在tp框架中寫(xiě)了一個(gè)圖書(shū)詳情分頁(yè)的,代碼如下:
public function verify_details(){ $sell_order_num=input('sell_order_num');$res=DB::table('verif')->where(['sell_order_num'=>$sell_order_num])->paginate(10);// 模板變量賦值$this->assign('list',$res);$this->assign('sell_order_num',$sell_order_num);return $this->view->fetch('Index/verify_details'); }前端模板通過(guò)以下代碼
<div class='list-page'> {$list->render()}</div>完成了分頁(yè)顯示能用,但是如何才能實(shí)現(xiàn)攜帶數(shù)據(jù)sell_order_num傳遞到verify_details方法中去進(jìn)行下次檢索呢?
這個(gè)問(wèn)題我也不會(huì),于是我問(wèn)了GPT3.5,成功解決
解決辦法-它的回答:可以在分頁(yè)鏈接中添加參數(shù),將sell_order_num數(shù)據(jù)傳遞到verify_details方法中。具體實(shí)現(xiàn)方法如下:
在模板中修改分頁(yè)鏈接,添加sell_order_num參數(shù):
<div class='list-page'> {$list->appends(['sell_order_num' => $sell_order_num])->render()}</div>在verify_details方法中獲取sell_order_num參數(shù)(不變):
public function verify_details(){ $sell_order_num = input('sell_order_num'); $res = DB::table('verif')->where(['sell_order_num'=>$sell_order_num])->paginate(10); // 模板變量賦值 $this->assign('list',$res); $this->assign('sell_order_num',$sell_order_num); return $this->view->fetch('Index/verify_details');}這樣就可以在分頁(yè)時(shí)攜帶sell_order_num數(shù)據(jù)傳遞到verify_details方法中了。
測(cè)試成功可以攜帶訂單號(hào)參數(shù)進(jìn)行翻頁(yè)
到此這篇關(guān)于Thinkphp5分頁(yè)后攜帶參數(shù)進(jìn)行跳轉(zhuǎn)傳遞的文章就介紹到這了,更多相關(guān)Thinkphp5分頁(yè)攜帶參數(shù)跳轉(zhuǎn)內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
