图像没有在yii2中传递旋转木马

时间:2016-08-29 02:03:51

标签: twitter-bootstrap yii2

我正在使用漂亮的网址。滑块工作正常,我可以看到,但是行李没有滑动。我不确定是不是因为漂亮还是我错过了什么 我的图像来源是 - C:\ xampp \ htdocs \ amitopticals \ frontend \ images。 索引文件的代码 -

<?php

/* @var $this yii\web\View */

$this->title = 'Amit Opticals';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-index">
    <div class="body-content">
        <div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
      <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
        <li data-target="#myCarousel" data-slide-to="3"></li>
      </ol>

      <!-- Wrapper for slides -->
      <div class="carousel-inner" role="listbox">
        <div class="item active">
          <img src="/amitopticals/frontend/images/image1.jpg" alt="AO">
        </div>

        <div class="item">
          <img src="/amitopticals/frontend/images/image2.jpg" alt="AO">
        </div>

        <div class="item">
          <img src="/amitopticals/frontend/images/image3.jpg" alt="AO">
        </div>

        <div class="item">
          <img src="/amitopticals/frontend/images/image4.jpg" alt="AO">
        </div>
      </div>

      <!-- Left and right controls -->
      <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
    </div>
</div>

当前输出 enter image description here

更新 我已将此页面的代码更改为以下内容。请注意,其他项目位置的图像工作正常。在下面的代码中 -

<div class="item active">
      <img src="/amitopticals/frontend/images/image1.jpg" alt="PS">
    </div>

不工作

<div class="item">
      <img src="/pse/advanced/frontend/images/images/image2.jpg" alt="PS">
    </div>

工作

我不确定我是否遗漏了什么。 index.php的完整代码

<?php

/* @var $this yii\web\View */

$this->title = 'Amit Opticals';
$this->params['breadcrumbs'][] = $this->title;
//$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-index">

  <div class="body-content">

        <div id="myCarousel" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
    <li data-target="#myCarousel" data-slide-to="3"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="/amitopticals/frontend/images/image1.jpg" alt="PS">
    </div>

    <div class="item">
      <img src="/pse/advanced/frontend/images/images/image2.jpg" alt="PS">
    </div>

    <div class="item">
      <img src="/pse/advanced/frontend/images/images/image3.jpg" alt="PS">
    </div>

    <div class="item">
      <img src="/pse/advanced/frontend/images/images/image4.jpg" alt="PS">
    </div>
  </div>

  <!-- Left and right controls -->
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

    </div>
</div>

htaccess文件

Options +FollowSymlinks
RewriteEngine On

# deal with backend first
RewriteCond %{REQUEST_URI} /(backend)
RewriteRule ^backend/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^backend/css/(.*)$ backend/web/css/$1 [L]
RewriteRule ^backend/image/(.*)$ backend/web/image/$1 [L]

RewriteCond %{REQUEST_URI} !/backend/web/(assets|css|image)/
RewriteCond %{REQUEST_URI} /(backend)
RewriteRule ^.*$ backend/web/index.php [L]


RewriteCond %{REQUEST_URI} /(assets|css|js|img|font)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
RewriteRule ^js/(.*)$ frontend/web/js/$1 [L]
RewriteRule ^image/(.*)$ frontend/web/image/$1 [L]

RewriteCond %{REQUEST_URI} !/(frontend|backend)/web/(assets|css|js|image|font)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php

1 个答案:

答案 0 :(得分:0)

在图片路径Yii::$app->request->baseUrl

前添加基本网址
<?php

/* @var $this yii\web\View */

$this->title = 'Amit Opticals';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-index">
    <div class="body-content">
        <div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
      <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
        <li data-target="#myCarousel" data-slide-to="3"></li>
      </ol>

      <!-- Wrapper for slides -->
      <div class="carousel-inner" role="listbox">
        <div class="item active">
          <img src="<?=Yii::$app->request->baseUrl?>/frontend/images/image1.jpg" alt="AO">
        </div>

        <div class="item">
          <img src="<?=Yii::$app->request->baseUrl?>/frontend/images/image2.jpg" alt="AO">
        </div>

        <div class="item">
          <img src="<?=Yii::$app->request->baseUrl?>/frontend/images/image3.jpg" alt="AO">
        </div>

        <div class="item">
          <img src="<?=Yii::$app->request->baseUrl?>/frontend/images/image4.jpg" alt="AO">
        </div>
      </div>

      <!-- Left and right controls -->
      <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
    </div>
</div>