yii 在bootstrap 4捆绑包文件后包含js

vof42yt1  于 2022-11-09  发布在  Bootstrap
关注(0)|答案(1)|浏览(170)

我尝试在bootstrap.bundle.js之后包含js文件。我的视图中有此内容

$this->registerJsFile('https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js', ['depends' => [yii\bootstrap4\BootstrapAsset::className()]]);
 $this->registerCssFile('https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css', ['depends' => [yii\bootstrap4\BootstrapAsset::className()]]);

但是当我查看源代码时。它仍然显示在它上面。有什么想法如何解决这个问题吗?谢谢

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.js"></script>

<script src="/yii2/frontend/web/assets/949bae38/yii.js"></script>

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.18/dist/sweetalert2.all.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/mhayes-twentytwenty/2.0.0-beta.1/jquery.twentytwenty.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>

<script src="/yii2/frontend/web/assets/949bae38/yii.validation.js"></script>

<script src="/yii2/frontend/web/assets/949bae38/yii.activeForm.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>

<script src="/yii2/frontend/web/assets/536f059b/js/bootstrap.bundle.js"></script>
hivapdat

hivapdat1#

yii\bootstrap4\BootstrapAsset只加载bootstrap.css文件。bootstrap.bundle.js由yii\bootstrap4\BootstrapPluginAsset加载。您只需在该调用中更改Asset类,如下所示:

$this->registerJsFile(
    'https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js',
    ['depends' => [yii\bootstrap4\BootstrapPluginAsset::className()]]
);

相关问题