thikphp-jump
适用于thikphp6.0的跳转扩展
安装composerrequireliliuwei/thikphp-jump配置//安装之后会在cofig目录里生成jump.php配置文件retur[//默认跳转页面对应的模板文件'dispatch_success_tmpl'=>app()->getRootPath().'/vedor/liliuwei/thikphp-jump/src/tpl/dispatch_jump.tpl','dispatch_error_tmpl'=>app()->getRootPath().'/vedor/liliuwei/thikphp-jump/src/tpl/dispatch_jump.tpl',];用法示例使用use\liliuwei\thik\Jump;
在所需控制器内引用该扩展即可:
<?phpamespaceapp\admi\cotroller;classIdex{use\liliuwei\thik\Jump;publicfuctiodemo1(){/***操作成功跳转的快捷方法*@parammixed$msg提示信息*@paramstrig$url跳转的URL地址*@parammixed$data返回的数据*@paramiteger$wait跳转等待时间*@paramarray$header发送的Header信息*///一般用法retur$this->success('登录成功','idex/idex');//完整用法//retur$this->success($msg='登录成功',$url='idex/idex',$data='',$wait=3,$header=[]);}publicfuctiodemo2(){/***操作错误跳转的快捷方法*@parammixed$msg提示信息*@paramstrig$url跳转的URL地址*@parammixed$data返回的数据*@paramiteger$wait跳转等待时间*@paramarray$header发送的Header信息*///一般用法retur$this->error('登录失败');//retur$this->success('登录失败','logi/idex');//完整用法//retur$this->error($msg='登录失败',$url='logi/idex',$data='',$wait=3,$header=[]);}publicfuctiodemo3(){/***URL重定向*@paramstrig$url跳转的URL表达式*@paramiteger$codehttpcode*@paramarray$with隐式传参*///一般用法//第一种方式:直接使用完整地址(/打头)//retur$this->redirect('/admi/idex/idex');//第二种方式:如果你需要自动生成URL地址,应该在调用之前调用url函数先生成最终的URL地址。retur$this->redirect(url('idex/idex',['ame'=>'thik']));//retur$this->redirect('https://www.thikphp.c');//完整用法//retur$this->redirect($url='/admi/idex/idex',$code=302,$with=['data'=>'hello']);}publicfuctiodemo4(){/***返回封装后的API数据到客户端*@parammixed$data要返回的数据*@paramiteger$code返回的code*@parammixed$msg提示信息*@paramstrig$type返回数据格式*@paramarray$header发送的Header信息*///一般用法retur$this->result(['userame'=>'liliuwei','sex'=>'男']);//完整用法//retur$this->result($data=['userame'=>'liliuwei','sex'=>'男'],$code=0,$msg='',$type='',$header=[]);}}
评论