TP5中redirect实现重定向及带参数跳转

Posted on 2022-07-26 15:30  君子不卿  阅读(968)  评论(0编辑  收藏  举报

1.控制器 重定向url传参

try{
   $result = Db::name('wupin')->insert($ist);
   if($result){
   $this->redirect(url('wupin_index', ['bid' => $bid, 'process_id' => $process_id]));
   }else{
       return json(['code' => 0, 'data' => '', 'msg' => '添加失败']);
   }
   }catch( PDOException $e){
       return json(['code' => 0, 'data' => '', 'msg' => $e->getMessage()]);
   }

 跳转的页面进行参数接收

$process_id=input('process_id');
$bid=input('bid');

2. html页面传递参数

var process_id=$("#process_id").val();
//环境物品清单,去其他页面
if(process_id==1||process_id==3){
    var url="{:url('show/wupin_index')}?bid="+id+"&process_id="+process_id;
}else if(process_id==4){
    var url="{:url('show/bl_index_index')}?bid="+id+"&process_id="+process_id;
}
else{
    var url="{:url('show/edit_assist')}?bid="+id+"&process_id="+process_id;
}

跳转到的控制器进行接收URL

$process_id=request()->get("process_id");
$bid=request()->get("bid");

Copyright © 2024 君子不卿
Powered by .NET 9.0 on Kubernetes

//评论