<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                application\index\controller\Index.php ~~~ namespace app\index\controller; class Index { //前置操作 add、edit等一定要小寫(方法定義可以使用駝峰的但是列表里面的方法名只能寫小寫的) protected $beforeActionList = [ 'beforeAction1',//當前所有方法都調用beforeAction1這個前置方法 'beforeAction2' => ['except'=>'index'],//除了index這個方法,其他所有方法都調用beforeAction2這個前置方法 'beforeAction3' => ['only'=>'add,edit'],//只有add、edit調用beforeAction3這個前置方法 ]; public function _initialize() { echo 'init<br/>'; } public function index() { return new \think\View\View()->fetch('index'); //或者 return view('index'); } } ~~~ 如果繼承了`think\Controller`類的話,可以直接調用`think\View`及`think\Request`類的方法,例如: ~~~ namespace app\index\controller; use think\Controller; class Index extends Controller { //前置操作 add、edit等一定要小寫(方法定義可以使用駝峰的但是列表里面的方法名只能寫小寫的) protected $beforeActionList = [ 'beforeAction1',//當前所有方法都調用beforeAction1這個前置方法 'beforeAction2' => ['except'=>'index'],//除了index這個方法,其他所有方法都調用beforeAction2這個前置方法 'beforeAction3' => ['only'=>'add,edit'],//只有add、edit調用beforeAction3這個前置方法 ]; public function _initialize() { if(true){ $this->success('新增成功', 'User/list'); }else{ $this->error('新增失敗'); } //如果想修改錯誤和成功時跳轉的默認的模版,參見跳轉與重定向章節 } public function index() { // 獲取包含域名的完整URL地址 $this->assign('domain',$this->request->url(true)); return $this->fetch('index'); //return $this->view->fetch('index'); } } ~~~ ## **多級控制器** application/admin/controller/v1/Blog.php ``` namespace app\admin\controller\v1; use think\Controller; class Blog extends Controller { public function index() { return $this->fetch(); } public function add() { return $this->fetch(); } public function edit($id) { return $this->fetch(); } } //訪問地址可以使用 http://serverName/admin.php/admin/v1.blog/index //如果要在路由定義中使用多級控制器,可以使用: \think\Route::get('blog/add','admin/v1.Blog/add'); ``` 默認情況下,控制器的返回輸出不會做任何的數據處理,但可以設置輸出格式,并進行自動的數據轉換處理,前提是控制器的輸出數據必須采用`return`的方式返回 當我們設置輸出數據格式為JSON: ~~~ // 默認輸出類型(默認html) 'default_return_type' => 'json', ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看