网站首页 > 开源技术 正文
会自动加载 Yii、JQuery 和 Bootstrap 等脚本和样式,但有时项目中可能并不需要这些库,或者使用其他版本;下面介绍如何去掉这些库脚本和样式。
? 去除 Yii.js 相关脚本
编辑 frontend\asset\AppAsset.php 文件,注释掉变量
$depends
里的'yii\web\YiiAsset'
值。编辑 frontend\config\main.php 文件,在字段
'components'
下面添加配置:'assetManager' => [ 'bundles' => [ 'yii\web\YiiAsset' => [ 'js' => [], // 去除 yii.js 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件 ], 'yii\widgets\ActiveFormAsset' => [ 'js' => [], // 去除 yii.activeForm.js 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件 ], 'yii\validators\ValidationAsset' => [ 'js' => [], // 去除 yii.validation.js 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件 ], ], ],
? 去除 JQuery 脚本
编辑 frontend\config\main.php 文件,在字段
'components'
下面添加配置:
'assetManager' => [ 'bundles' => [ 'yii\web\JqueryAsset' => [ 'js' => [], // 去除 jquery.js 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件 ], ], ],
? 去除 Bootstrap 库
编辑 frontend\asset\AppAsset.php 文件,注释掉变量
$depends
里的'yii\bootstrap\BootstrapAsset'
值。编辑 frontend\config\main.php 文件,在字段
'components'
下面添加配置:'assetManager' => [ 'bundles' => [ 'yii\bootstrap\BootstrapAsset' => [ 'css' => [], // 去除 bootstrap.css 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件 ], 'yii\bootstrap\BootstrapPluginAsset' => [ 'js' => [], // 去除 bootstrap.js 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件 ], ], ],
猜你喜欢
- 2024-09-11 少年歌行。第2部。萧崇登基后……
- 2024-09-11 少年歌行2:司空千落怀孕,萧瑟居然要娶别人为妻
- 2024-09-11 YII框架学习(新手)NO.2(yii框架设计模式)
- 2024-09-11 yii安装与使用详解(easy_install安装)
- 2024-09-11 小编教你 YII2框架模块如何绑定二级域名
- 2024-09-11 一款基于Yii2+Vue2.0+uniapp的开源商城
- 2024-09-11 一款基于Yii2开发的免费商城系统(开发一款游戏的步骤)
- 2024-09-11 Yii2连接pgsql,设置默认schema(sqlplus默认连库)
- 2024-09-11 php生命周期、Laravel生命周期、Yii2生命周期、ThinkPHP生命周期
- 2024-09-11 [开源推荐] yii2-cdn 支持七牛、网易云、腾讯云、阿里云的cdn
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)