如何在Yii2中删除已注册的jquery文件

Mav*_*ick 5 jquery yii2 active-form

在使用Yii2时,我遇到了jquery文件的问题.在布局中我已经注册了一个jquery-1.10.2.min.js文件.但是在内部页面中使用ActiveForm它然后它还包括来自资产的jquery文件.

使用时有没有办法jquery-1.10.2.min.js在任何页面上删除ActiveForm

非常感谢,

M.

soj*_*oju 5

是的,您应该修改assetManager组件配置:

return [
    // ...
    'components' => [
        'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'sourcePath' => null,   // do not publish the bundle
                    'js' => [
                        '//code.jquery.com/jquery-1.10.2.min.js',  // use custom jquery
                    ]
                ],
            ],
        ],
    ],
];
Run Code Online (Sandbox Code Playgroud)

它将加载自定义jquery(无需注册).

阅读更多:http://www.yiiframework.com/doc-2.0/guide-structure-assets.html#customizing-asset-bundles