PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

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

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

下面thinkphp框架教程栏目将给大家讲介绍关于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视频教程

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