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

Include js after bootstrap 4 bundle file

我试图在 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>

yii\bootstrap4\BootstrapAsset 只加载 bootstrap.css 文件。 bootstrap.bundle.js 由 yii\bootstrap4\BootstrapPluginAsset 加载。 您只需要像这样更改该调用中的资产 class:

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