<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 功能強大 支持多語言、二開方便! 廣告
                > 變量如果要在模板中使用,就必須先進行模板賦值才可以,但系統變量和配置參數可以不用賦值(我們會在模板章節介紹如何輸出) ## 控制器基類的assign方法 ``` <?php namespace app\demo\controller; use cmf\controller\HomeBaseController; class IndexController extends HomeBaseController { public function index() { // 單個變量賦值 $this->assign("hello", "Hello ThinkCMF!"); // 多個變量批量賦值 $this->assign([ 'hello' => 'Hello ThinkCMF!', 'username' => '老貓' ]); return $this->fetch(':index'); } } ``` ## 傳入參數方法 控制器基類的`fetch` 和`display` 方法都可以通過參數傳入模版變量,如: fetch方法: ```php <?php namespace app\demo\controller; use cmf\controller\HomeBaseController; class IndexController extends HomeBaseController { public function index() { return $this->fetch(':index',[ 'hello' => 'Hello ThinkCMF!', 'username' => '老貓' ]); } } ``` display 方法: ```php <?php namespace app\demo\controller; use cmf\controller\HomeBaseController; class IndexController extends HomeBaseController { public function index() { $content = '{$hello}'."\n".'{$username}'; return $this->display($content,[ 'hello' => 'Hello ThinkCMF!', 'username' => '老貓' ]); } } ``` ## View 類的share方法 此方法支持在任何地方使用進行模板變量賦值,如: ```php \think\facade\View::share('public_name', 'this is a name'); // 或者批量賦值 \think\facade\View::share([ 'public_name1' => 'this is a name1', 'public_name2' => 'this is a name2' ]); ``` 通過此方法設置的模板變量最后會和上面幾種方法賦值的變量合并。 ## 變量輸出 通過以上方法賦值后,就可以在模板里使用這些變量,這里演示一下變量的輸出,更多變量操作會在模板章節說明; ```php <div>{$hello}</div> <div>{$username}</div> ```
                  <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>

                              哎呀哎呀视频在线观看