【问题标题】:Bootstrap carousel not working in Heroku app引导轮播在 Heroku 应用程序中不起作用
【发布时间】:2015-04-27 20:17:26
【问题描述】:

我将 CDN 中的引导程序与我的 rails 应用程序一起使用。除了主页上的轮播外,大多数样式都有效。它在开发中运行良好,但在 Heroku 中却不行。我不知道这是否相关,但我已经在 routes.rb 中定义了这条路线:root "home#index",它通过 HomeController 显示 index.html.erb。轮播中的第一张图片已加载,仅此而已。它没有任何功能。现在我在 gem 文件中没有引导 gem,如有必要我会尝试。我只是想看看是否有人以前见过这个问题并且知道该怎么做。我认为这个文件没问题,因为它可以在开发中使用,但这里是 index.html.erb:

<div id="myCarousel" class="carousel slide img-rounded" 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>
  <li data-target="#myCarousel" data-slide-to="4"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
  <%= image_tag("nicholson2.jpg", alt:"nicholson", class: "img-rounded") %>
</div>

<div class="item">
  <%= image_tag("marilyn2.jpg", alt:"marilyn", class: "img-rounded") %>
</div>

<div class="item">
  <%= image_tag("pacino2.jpg", alt:"pacino", class: "img-rounded") %>
</div>

<div class="item">
  <%= image_tag("lily.jpg", alt:"lily", class: "img-rounded") %>
</div>

<div class="item">
  <%= image_tag("deniro2.jpg", alt:"deniro", class: "img-rounded") %>
</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>

【问题讨论】:

  • 如果您只是发布 heroku 应用程序的链接,这是最简单的。我的猜测是您的 heroku 应用程序没有提供 js 资产。
  • 这是我的风格标签中的错字。我有 http: 而不是 https:
  • 然后解决了吗? :)

标签: ruby-on-rails twitter-bootstrap heroku


【解决方案1】:

我在链接到外部资源时使用 https: 而不是 http: 解决了这个问题。它在开发中有效,但显然 heroku 不允许这样做。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,在我的情况下,我必须从 application.js 文件 (assets/javascripts/application.js) 中删除 //=require jquery_ujs。希望它能解决问题。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-12
      • 2020-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-01
      相关资源
      最近更新 更多