在yii2中从bootstrap 4降级到3 [英] Downgrading from bootstrap 4 to 3 in yii2
问题描述
我目前正在使用yii2框架进行项目.我想尝试将Bootstrap 4.0与我的项目一起使用,并在我的 composer.json
文件中添加"yiisoft/yii2-bootstrap":"~2.1.0@dev"
进行了 composer更新
.
I was currently working on a project using the yii2 framework. I wanted to try out using bootstrap 4.0 with my project and added "yiisoft/yii2-bootstrap": "~2.1.0@dev"
to my composer.json
file and ran composer update
.
这成功在项目中安装了bootstrap 4.0.0,但是当我开始浏览我的项目以查看受到影响时,我意识到 yii \ bootstrap \ Modal
组件无法正常工作.
This successfully installed bootstrap 4.0.0 in the project but when I started to browse my project to see what was affected I realized that the yii\bootstrap\Modal
component was not working.
因此,我想将项目恢复为使用bootstrap 3,并将 composer.json
文件中的条目更改为"yiisoft/yii2-bootstrap":〜2.0.0"
并进行了 composer更新
,但出现以下错误
Because of this, I want to revert my project back to using bootstrap 3 and changed my entry in the composer.json
file to "yiisoft/yii2-bootstrap": "~2.0.0"
and did a composer update
but got the following error
Your requirements could not be resolved to an installable set of packages.
Problem 1
- yiisoft/yii2-bootstrap 2.0.8 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.7 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.6 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.5 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.4 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.3 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.2 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.1 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
- yiisoft/yii2-bootstrap 2.0.0 requires bower-asset/bootstrap 3.2.* | 3.1.* -> no matching package found.
- Installation request for yiisoft/yii2-bootstrap ~2.0.0 -> satisfiable by yiisoft/yii2-bootstrap[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
是我做错了什么,还是有其他方法可以降级到Bootstrap 3?
Is there something that I'm doing wrong or is there another way I can downgrade back to bootstrap 3?
感谢您的任何建议.
推荐答案
您可以映射 assetManager
来加载jquery和bootstrap文件的特定版本,我在上一个项目中也做过同样的事情,我将所有内容保持最新,并仅使用以下配置加载了 bootstrap 3
文件,您可以在 frontend/config/main中的
. components
下添加以下内容.php
You can map the assetManager
to load the specific versions for the jquery and bootstrap files I also did the same in my previous project, I kept everything up to date and just used the following configurations to load the bootstrap 3
files, you can add the below under components
in frontend/config/main.php
.
'assetManager' => [
'bundles' => [
'yii\web\JqueryAsset' => [
'sourcePath' => null , 'js' => [ '//code.jquery.com/jquery-2.2.4.min.js' ] ,
] ,
'yii\bootstrap\BootstrapAsset' => [
'sourcePath' => null , 'css' => [ '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' ] ,
] ,
'yii\bootstrap\BootstrapPluginAsset' => [
'sourcePath' => null , 'js' => [ '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' ] ,
] ,
] ,
] ,
这篇关于在yii2中从bootstrap 4降级到3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!