今天突然發現用Bootstrap 中的導航組件寫的功能沒效果了,查看原理是沒有加載到bootstrap.js文件,添加depends就好了。
<?php
namespace frontend\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
'js/main.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapPluginAsset',//添加這句就好了
];
}
return [
// ...
'components' => [
'assetManager' => [
'bundles' => [
'yii\web\JqueryAsset' => [
'sourcePath' => null, // do not publish the bundle
YII_ENV_DEV ? 'jquery.js' : 'jquery.min.js'
]
],
],
],
],
];