<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Widget擴展 [上一頁](# "上一頁")[下一頁](# "下一頁") Widget擴展一般用于頁面組件的擴展。 舉個例子,我們在頁面中實現一個分類顯示的Widget,首先我們要定義一個Widget控制器層 CateWidget,如下: ~~~ namespace Home\Widget; use Think\Controller; class CateWidget extends Controller { public function menu(){ return 'menuWidget'; } } ~~~ 然后,我們在模版中通過W方法調用這個Widget。 ~~~ {:W('Cate/Menu')} ~~~ 執行后的輸出結果是: menuWidget 如果,CateWidget類的menu方法改成: ~~~ namespace Home\Widget; use Think\Controller; class CateWidget extends Controller { public function menu(){ echo 'menuWidget'; } } ~~~ 模版中的用法則需要改成: ~~~ {~W('Cate/Menu')} ~~~ ### 傳入參數 如果需要在調用Widget的時候 使用參數,可以這樣定義: ~~~ namespace Home\Widget; use Think\Controller; class CateWidget extends Controller { public function menu($id,$name){ echo $id.':'.$name; } } ~~~ 模版中的參數調用,使用: ~~~ {:W('Cate/Menu',array(5,'thinkphp'))} ~~~ > 傳入的參數是一個數組,順序對應了menu方法定義的參數順序。 則會輸出 ~~~ 5:thinkphp ~~~ ### 模板支持 Widget可以支持使用獨立的模板,例如: ~~~ namespace Home\Widget; use Think\Controller; class CateWidget extends Controller { public function menu(){ $menu = M('Cate')->getField('id,title'); $this->assign('menu',$menu); $this->display('Cate:menu'); } } ~~~ CateWiget類渲染了一個模版文件 `View/Cate/menu.html`。在menu.html模版文件中的用法: ~~~ <foreach name="menu" item="title"> {$key}:{$title} </foreach> ~~~ [上一頁](# "上一頁")[下一頁](# "下一頁")
                  <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>

                              哎呀哎呀视频在线观看