1. <small id='2vM1A'></small><noframes id='2vM1A'>

        <tfoot id='2vM1A'></tfoot>

      2. <i id='2vM1A'><tr id='2vM1A'><dt id='2vM1A'><q id='2vM1A'><span id='2vM1A'><b id='2vM1A'><form id='2vM1A'><ins id='2vM1A'></ins><ul id='2vM1A'></ul><sub id='2vM1A'></sub></form><legend id='2vM1A'></legend><bdo id='2vM1A'><pre id='2vM1A'><center id='2vM1A'></center></pre></bdo></b><th id='2vM1A'></th></span></q></dt></tr></i><div id='2vM1A'><tfoot id='2vM1A'></tfoot><dl id='2vM1A'><fieldset id='2vM1A'></fieldset></dl></div>
        <legend id='2vM1A'><style id='2vM1A'><dir id='2vM1A'><q id='2vM1A'></q></dir></style></legend>

          <bdo id='2vM1A'></bdo><ul id='2vM1A'></ul>

        如何在 AppAsset 类中向 yii2 依赖项添加条件?

        How can I add conditions to yii2 depends in AppAsset class?(如何在 AppAsset 类中向 yii2 依赖项添加条件?)
          <tbody id='0ylV9'></tbody>

        <small id='0ylV9'></small><noframes id='0ylV9'>

      3. <tfoot id='0ylV9'></tfoot>
          <legend id='0ylV9'><style id='0ylV9'><dir id='0ylV9'><q id='0ylV9'></q></dir></style></legend>

              <i id='0ylV9'><tr id='0ylV9'><dt id='0ylV9'><q id='0ylV9'><span id='0ylV9'><b id='0ylV9'><form id='0ylV9'><ins id='0ylV9'></ins><ul id='0ylV9'></ul><sub id='0ylV9'></sub></form><legend id='0ylV9'></legend><bdo id='0ylV9'><pre id='0ylV9'><center id='0ylV9'></center></pre></bdo></b><th id='0ylV9'></th></span></q></dt></tr></i><div id='0ylV9'><tfoot id='0ylV9'></tfoot><dl id='0ylV9'><fieldset id='0ylV9'></fieldset></dl></div>

                • <bdo id='0ylV9'></bdo><ul id='0ylV9'></ul>

                  本文介绍了如何在 AppAsset 类中向 yii2 依赖项添加条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Yii2 的 AppAsset 类中有一些依赖:

                  There are some depends in AppAsset class in Yii2:

                  public $depends = [
                      'yiiwebYiiAsset',
                      'yiiootstrapBootstrapAsset'
                  ];
                  

                  有没有办法像我用 css 和 js 那样为此依赖添加条件?

                  Is there any way to add conditions for this depends like I do it with css and js?

                  public $jsOptions = ['condition' => 'lt IE 7']; 
                  

                  或者,您知道另一种向 bootstrap 和 yii JS 和 CSS 文件添加条件的方法吗?
                  谢谢

                  Or, may be, you know another way to add conditions to bootstrap and yii JS and CSS files?
                  Thanks

                  UPD:我已添加到 config/web.php:

                  UPD: I've added to config/web.php:

                  'components' => [
                  'assetManager' => [
                      'bundles' => [
                          'yiiwebYiiAsset' => [
                              'jsOptions' => ['condition' => 'lt IE 7'],
                          ],
                          'yiiootstrapBootstrapAsset' => [
                              'jsOptions' => ['condition' => 'lt IE 7'],
                          ],
                      ],
                  ],
                  

                  但是,我有这个(正如@arogachev 推荐的那样):

                  But, I've got this (as @arogachev recommends):

                  <script src="/assets/8fd244c6/jquery.js"></script>
                  <!--[if lt IE 7]>
                  <script src="/assets/bd48c465/yii.js"></script>
                  <![endif]-->
                  <script src="/assets/bd48c465/yii.gridView.js"></script>
                  <script src="/assets/db9cb9aa/js/bootstrap.js"></script>
                  

                  UPD2:答案

                  'yiiwebYiiAsset' => [
                              'cssOptions'    => ['condition' => 'gt IE 7]>'],
                              'jsOptions'     => ['condition' => 'gt IE 7]>'],
                          ],
                          'yiiootstrapBootstrapAsset' => [
                              'cssOptions'    => ['condition' => 'gt IE 7]>'],
                          ],
                          'yiiootstrapBootstrapPluginAsset' => [
                              'jsOptions'     => ['condition' => 'gt IE 7]>'],
                          ],
                          'yiiwebJqueryAsset' => [
                              'jsOptions'     => ['condition' => 'gt IE 7]>'],
                              'cssOptions'    => ['condition' => 'gt IE 7]>'],
                          ],
                  

                  推荐答案

                  您可以像这样通过应用程序配置自定义供应商捆绑包:

                  You can customize vendor bundles through application config like that:

                  return [
                      // ...
                      'components' => [
                          'assetManager' => [
                              'bundles' => [
                                  'yiiwebYiiAsset' => [
                                      'jsOptions' => ['condition' => 'lt IE 7'],
                                  ],
                                  'yiiootstrapBootstrapAsset' => [
                                      'jsOptions' => ['condition' => 'lt IE 7'],
                                  ],
                              ],
                          ],
                      ],
                  ];
                  

                  或者在运行时通过assetManager:

                  use Yii;
                  
                  ...
                  
                  Yii::$app->assetManager->bundles['yiiwebYiiAsset']->jsOptions = ['condition' => 'lt IE 7'];
                  
                  Yii::$app->assetManager->bundles['yiiootstrapBootstrapAsset']->jsOptions = ['condition' => 'lt IE 7'];
                  

                  官方文档:

                  • 自定义资产包

                  这篇关于如何在 AppAsset 类中向 yii2 依赖项添加条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <tfoot id='aug6U'></tfoot>
                  1. <small id='aug6U'></small><noframes id='aug6U'>

                      <tbody id='aug6U'></tbody>
                  2. <i id='aug6U'><tr id='aug6U'><dt id='aug6U'><q id='aug6U'><span id='aug6U'><b id='aug6U'><form id='aug6U'><ins id='aug6U'></ins><ul id='aug6U'></ul><sub id='aug6U'></sub></form><legend id='aug6U'></legend><bdo id='aug6U'><pre id='aug6U'><center id='aug6U'></center></pre></bdo></b><th id='aug6U'></th></span></q></dt></tr></i><div id='aug6U'><tfoot id='aug6U'></tfoot><dl id='aug6U'><fieldset id='aug6U'></fieldset></dl></div>

                      <legend id='aug6U'><style id='aug6U'><dir id='aug6U'><q id='aug6U'></q></dir></style></legend>
                          <bdo id='aug6U'></bdo><ul id='aug6U'></ul>