【问题标题】:What is renderPartial() function in Yii?Yii 中的 renderPartial() 函数是什么?
【发布时间】:2015-07-13 23:15:59
【问题描述】:

我是yiibie,我想知道renderPartial()是什么,它是如何工作的,我们在哪里使用它?请详细说明。

【问题讨论】:

    标签: php yii renderpartial


    【解决方案1】:

    renderPartial documentation 足够清晰,可以理解。

    渲染视图。

    命名视图是指一个 PHP 脚本(通过 getViewFile 解析),它 包含在此方法中。如果 $data 是一个关联数组,它将 提取为 PHP 变量并提供给脚本。

    此方法与 render() 的不同之处在于它不应用布局 到渲染结果。因此,它主要用于渲染部分 查看或 AJAX 响应。

    因此,当您需要显示带有布局的整个页面时,您可以使用 render()。如果您只想显示视图 html,请使用 renderPartial()。

    class Controller extends CController {
      // Main page
      public function actionIndex(){
        $this->render('index');
      }
    
      // For example, additional content uploaded via AJAX after page is loaded
      public function actionInfo(){
        $this->renderPartial('info');
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多