編程學習網 > 編程教程 > Yii2.0 視頻教程
2015
10-19

Yii2.0視頻第十講——深入理解View——基本功能(Render、JS、CSS)

清華大佬耗費三個月吐血整理的幾百G的資源,免費分享!....>>>

Render方法

$this->render('about.php',['test'=>5]);
             
$content = $this->renderPartial('about',['test'=>5]);
             
$this->renderContent($content);
             
$this->renderFile('full file name',['test'=>5]);
             
$this->renderAjax('about',['test'=>'test']);


查找view文件的5種方式

  • 別名開頭,路徑指定view文件
    @app/views/site/about.php
  • //開頭,使用 app目錄下面的views
    //site/about.php
  • /開頭,使用當前Module中的views
    /site/about.php
  • 直接使用字符串,ViewContextInterface接口返回的view
    about,login
  • 上次所使用


在view中添加資源
  • meta標簽、
  • link標簽
  • 添加css、js代碼
  • 引入css、js文件,以及先后順序

在線播放

下載地址

掃碼二維碼 獲取免費視頻學習資料

編程學習