其他分享
首页 > 其他分享> > TP5中redirect实现重定向及带参数跳转

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

作者:互联网

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");

标签:redirect,index,process,bid,url,TP5,跳转,var,id
来源: https://www.cnblogs.com/junzibuqing/p/16521214.html