thinkphp5的前置操作

  • 时间:
  • 浏览:
  • 来源:互联网
namespace app\test\controller;

use think\Controller;

class Before extends Controller 
{

    protected $beforeActionList = [                 // 必须引入Controller
        "first",                                                  // one,two,three都可以在调用前调用first,
        "second" => [ "except" => "one" ],      // 只有one不能调用second
        "thrid" => [ "only" => "two,three" ]       // 只有two和three在调用前可以调用thrid
    ];

    protected function first()
    {
        echo "first";
    }

    protected function second()
    {
        echo "second";
    }

    protected function thrid()
    {
        echo "thrid";
    }

    public function index()
    {
        return 'index';
    }

    public function one()
    {
        echo 'one';
    }

    public function two()
    {
        echo 'two';
    }

    public function three()
    {
        echo 'three';
    }

}

本文链接http://element-ui.cn/news/show-340088.aspx