久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      yii2如何引入js文件

      yii2如何引入js文件

      問(wèn)題:

      比如,我在web文件夾下建立css文件和js文件,在assets建立資源控制器。那么我在view層的時(shí)候怎么調(diào)用web/css/test.css或者web/js/test/js文件呢?

      方法如下:

      一、模塊引用(該模塊的所有頁(yè)面都會(huì)引用)

      Yii2對(duì)于CSS/JS 管理,使用AssetBundle資源包類。

      (推薦教程:yii框架)

      (注:YII2基礎(chǔ)版 assets/AppAsset.php,YII2高級(jí)版 frontend/assets/AppAsset.php,這里以基礎(chǔ)版為例)

      namespace appassets; use yiiwebAssetBundle; /**  * @author Qiang Xue <qiang.xue@gmail.com>  * @since 2.0  */ class AppAsset extends AssetBundle {     public $basePath = '@webroot';     public $baseUrl = '@web';     //全局css 在這個(gè)添加css文件     public $css = [         'css/site.css',         'css/test.css',     ];     //全局js  在這里添加js文件     public $js = [         'js/test.js',     ];     //依賴關(guān)系     public $depends = [         'yiiwebYiiAsset',         'yiibootstrapBootstrapAsset',     ]; }

      二、在某個(gè)視圖文件中引用

      只需要在view文件中添加如下代碼就行了。

      //引用css文件,注意自己的文件路徑 <?php $this->registerCssFile('css/test.css');?> //引用js文件,注意自己的文件路徑<span class="redactor-invisible-space"></span> <?php $this->registerJsFile('js/test.js');?>

      想學(xué)習(xí)

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)