ThinkPHP6.0 问题整理

2020-04-05  本文已影响0人  皮蛋馅儿

1、Driver [Think] not supported.
报错场景:

<?php

namespace app\admin\controller;

use app\BaseController;
use think\facade\View;

class Index extends BaseController
{
    public function index()
    {
        return View::fetch();
    }
}

解决:

composer require topthink/think-view

2、BaseController无法跳转问题,可通过以下方法解决

<?php

namespace app\admin\controller;

use app\BaseController;
use think\exception\HttpResponseException;

class Base extends BaseController
{
    public function initialize()
    {
        parent::initialize();
        if ('条件成立') {
            return $this->redirect(url('index/index'), 302);
        }
    }

    /** 重定向
     * @param array ...$args
     */
    public function redirect(...$args)
    {
        throw new HttpResponseException(redirect(...$args));
    }
}

加我微信公众号:\color{red}{皮蛋馅儿},定期更新文章,一起学习哦~

上一篇 下一篇

猜你喜欢

热点阅读