【问题标题】:Downgrading from bootstrap 4 to 3 in yii2在 yii2 中从 bootstrap 4 降级到 3
【发布时间】:2018-09-27 17:27:48
【问题描述】:

我目前正在做一个使用 yii2 框架的项目。我想尝试在我的项目中使用 bootstrap 4.0,并将"yiisoft/yii2-bootstrap": "~2.1.0@dev" 添加到我的composer.json 文件并运行composer update

这成功地在项目中安装了 bootstrap 4.0.0,但是当我开始浏览我的项目以查看受影响的内容时,我意识到 yii\bootstrap\Modal 组件无法正常工作。

因此,我想将我的项目恢复为使用引导程序 3,并将我在 composer.json 文件中的条目更改为 "yiisoft/yii2-bootstrap": "~2.0.0" 并执行了 composer update,但出现以下错误

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.

我做错了什么还是有其他方法可以降级回引导程序 3?

感谢您提出的任何建议。

【问题讨论】:

  • 尝试composer remove yiisoft/yii2-bootstrap,然后重新安装

标签: twitter-bootstrap yii2 composer-php


【解决方案1】:

如果您使用的是fxpio/composer-asset-plugin,则这是known issue

您可以通过两种方式解决此问题:

  1. 删除vendor目录和composer.lock文件,然后运行composer update
  2. 切换到asset-packagist - 您需要卸载fxpio/composer-asset-plugin 并将存储库添加到您的作曲家。更多详情,请访问Yii documentation

【讨论】:

    【解决方案2】:

    您可以映射 assetManager 以加载 jquery 和 bootstrap 文件的特定版本 我在以前的项目中也做了同样的事情,我保持一切都是最新的,只是使用以下配置来加载 bootstrap 3 文件,您可以在frontend/config/main.php 中的components 下添加以下内容。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-15
      • 2018-07-15
      • 2020-05-16
      • 2019-07-14
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      • 2011-07-24
      相关资源
      最近更新 更多