Yii2禁用Bootstrap Js,JQuery和CSS [英] Yii2 disable Bootstrap Js, JQuery and CSS

查看:100
本文介绍了Yii2禁用Bootstrap Js,JQuery和CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与标题相同,我不想使用bootstrap.css和bootstrap.js.我尝试使用:

Same as title, i don't want using bootstrap.css and bootstrap.js. I try using:

'assetManager' => [
    'bundles' => [
        'yii\bootstrap\BootstrapAsset' => [
            'css' => [],
        ],
    ],
],

它删除bootstrap.css,但不能删除bootstrap.js.有人可以帮助我吗?

It remove bootstrap.css but can't remove bootstrap.js. Somebody can help me?

推荐答案

web.php配置文件中,将以下代码添加到组件数组中:

In web.php config file add the following code into components array:

'assetManager' => [
        'bundles' => [
            'yii\bootstrap\BootstrapPluginAsset' => [
                'js'=>[]
            ],
        ],
    ],

更全面:

以禁用CSS(bootstrap.css):

'assetManager' => [
    'bundles' => [
        'yii\bootstrap\BootstrapAsset' => [
            'css' => [],
        ],
    ],
],

以禁用JS(bootstrap.js):

'assetManager' => [
    'bundles' => [
        'yii\bootstrap\BootstrapPluginAsset' => [
            'js'=>[]
        ],
    ],
],

以禁用JQuery(jquery.js)

'assetManager' => [
    'bundles' => [
        'yii\web\JqueryAsset' => [
            'js'=>[]
        ],
    ],
],

要禁用所有这些功能:

'assetManager' => [
    'bundles' => [
        'yii\web\JqueryAsset' => [
            'js'=>[]
        ],
        'yii\bootstrap\BootstrapPluginAsset' => [
            'js'=>[]
        ],
        'yii\bootstrap\BootstrapAsset' => [
            'css' => [],
        ],

    ],
],


更新

如评论中提到的 Soju 所述,另一种替代方法是禁用位于./assets/中的AppAsset类中的这些文件,然后删除以下行:

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 = [
   'yii\web\YiiAsset',              #REMOVE
   'yii\bootstrap\BootstrapAsset',  #REMOVE
];

这篇关于Yii2禁用Bootstrap Js,JQuery和CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆