5

While working with Yii2, I am facing a problem with jquery files. In layout I have registered a jquery-1.10.2.min.js file. But in inner page as use ActiveForm then it includes jquery file from assets as well.

Is there any way to remove jquery-1.10.2.min.js on any page while using ActiveForm ?

Many Thanks,

M.

4

1 回答 1

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
                    ]
                ],
            ],
        ],
    ],
];

它将加载一个自定义 jquery(无需注册)。

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

于 2015-01-19T09:40:37.437 回答