首页  >  文章  >  php框架  >  thinkphp6不能用redirect重定向是什么情况?

thinkphp6不能用redirect重定向是什么情况?

藏色散人
藏色散人转载
2021-11-11 14:09:292220浏览

下面thinkphp框架教程栏目将给大家讲介绍关于thinkphp6不能用redirect重定向的问题,希望对需要的朋友有所帮助!

thinkphp6不能用redirect重定向是什么情况?

TP6在__construct_initialize中无法使用redirect重定向?

说明

目前版本 return redirect('index/index'); 在__construct和_initialize无法使用,可以安装之前的代码方便使用

安装

composer require liliuwei/thinkphp-jump

用法示例

<?php
namespace app\controller;
class Index 
{
    use \liliuwei\think\Jump; 
    public function index()
    {
        //return $this->error(&#39;error&#39;);
        //return $this->success(&#39;success&#39;,&#39;index/index&#39;);
        //return $this->redirect(&#39;/admin/index/index&#39;);
        return $this->result([&#39;username&#39; => &#39;liliuwei&#39;, &#39;sex&#39; => &#39;男&#39;]);  
    }
}

推荐:《最新的10个thinkphp视频教程

以上是thinkphp6不能用redirect重定向是什么情况?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:juejin.im。如有侵权,请联系admin@php.cn删除