我有我的yii2應用程序使用airani\bootstrap\BootstrapRtlAsset
RTL佈局。但是,我想使用this online tool來自定義Bootstrap。是否有更簡單的方法來設置依賴項Yii2資產
該工具會生成一個css文件,我希望它在bootstrap-rtl.css
來自BootstrapRtlAsset之前直接鏈接。
的唯一途徑,我知道,要做到這一點,在應用程序創建新AssetBundle /資產類似如下:
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'app\assets\ThemeAsset',
'airani\bootstrap\BootstrapRtlAsset',
];
:
<?php
namespace app\assets;
use yii\web\AssetBundle;
class ThemeAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/theme.min.css',
];
public $js = [
];
}
那麼我應該在$depends
AppAsset
的添加它
那麼是否有任何其他方式,允許我用css文件的路徑替換app\assets\ThemeAsset
css/theme.min.css
而不需要創建新的AssetBundle?
你說得對。它應該從佈局中使用,如果我想它應用於所有視圖,如下所示:'$ this-> registerCssFile('/ css/theme.min.css',['depends'=>'yii \ bootstrap \ BootstrapAsset']);'我們將'depends'選項設置爲BootstrapAsset,所以它在BootstrapRtlAsset之前。 – SaidbakR
@sємsєм:的確如此......你懂了......享受:) –