本篇文章主要介绍了详解yii2高级版引入bootstrap.js的一个办法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
在frontend/assets/AppAsset.php
代码示例
namespace frontend\assets;
use yii\web\AssetBundle;
/**
* Main frontend application asset bundle.
*/
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',//注意这里必须要有
'rmrevin\yii\fontawesome\AssetBundle',
];
}在vendor/yiisoft/yii2-bootstrap/BootstrapAsset.php 文件里
namespace yii\bootstrap;
use yii\web\AssetBundle;
/**
* Asset bundle for the Twitter bootstrap css files.
*
* @since 2.0
*/
class BootstrapAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap/dist';
public $css = [
'css/bootstrap.css',
];
//下面是增加的代码
public $js = [
'js/bootstrap.js',
];
}OK了
以上就是详解Yii2高级版引入bootstrap.js的示例代码的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号