Yii2 禁用 Bootstrap Js、JQuery 和 CSS [英] Yii2 disable Bootstrap Js, JQuery and CSS
问题描述
同标题,我不想使用 bootstrap.css 和 bootstrap.js.我尝试使用:
Same as title, i don't want using bootstrap.css and bootstrap.js. I try using:
'assetManager' => [
'bundles' => [
'yiiootstrapBootstrapAsset' => [
'css' => [],
],
],
],
它删除了 bootstrap.css 但不能删除 bootstrap.js.有人可以帮我吗?
It remove bootstrap.css but can't remove bootstrap.js. Somebody can help me?
推荐答案
在 web.php
配置文件中添加如下代码到 components 数组中:
In web.php
config file add the following code into components array:
'assetManager' => [
'bundles' => [
'yiiootstrapBootstrapPluginAsset' => [
'js'=>[]
],
],
],
更全面:
为了禁用 Css (bootstrap.css):
'assetManager' => [
'bundles' => [
'yiiootstrapBootstrapAsset' => [
'css' => [],
],
],
],
为了禁用JS(bootstrap.js):
'assetManager' => [
'bundles' => [
'yiiootstrapBootstrapPluginAsset' => [
'js'=>[]
],
],
],
为了禁用 JQuery (jquery.js)
'assetManager' => [
'bundles' => [
'yiiwebJqueryAsset' => [
'js'=>[]
],
],
],
为了禁用所有这些:
'assetManager' => [
'bundles' => [
'yiiwebJqueryAsset' => [
'js'=>[]
],
'yiiootstrapBootstrapPluginAsset' => [
'js'=>[]
],
'yiiootstrapBootstrapAsset' => [
'css' => [],
],
],
],
<小时>
更新
正如评论中提到的 Soju,另一种替代方法是在 AppAsset
类中禁用这些文件,该类位于 ./assets/
,然后删除以下几行:
As Soju mentioned in comments, another alternative way would be disabling these files in AppAsset
class, which is located in ./assets/
, then remove the following lines:
public $depends = [
'yiiwebYiiAsset', #REMOVE
'yiiootstrapBootstrapAsset', #REMOVE
];
这篇关于Yii2 禁用 Bootstrap Js、JQuery 和 CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!