Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
引导转盘(如何加载javascript?)_Javascript_Jquery_Css_Twitter Bootstrap_Ruby On Rails 4 - Fatal编程技术网

引导转盘(如何加载javascript?)

引导转盘(如何加载javascript?),javascript,jquery,css,twitter-bootstrap,ruby-on-rails-4,Javascript,Jquery,Css,Twitter Bootstrap,Ruby On Rails 4,我正在尝试实现一个引导转盘。因为某种原因它不会滑动。。。当我点击箭头滑动我的http://localhost:3000/转到http://localhost:3000/#carousel-通用示例 我相信我缺少必要的javascript需求,但不确定如何包含它们 它们放在什么档案里application.js或application.css.scss或在我的一个视图中 另外,需要包含哪些代码,是否必须放在页面中的特定位置?它是bootstrap.js还是bootstrap transition.

我正在尝试实现一个引导转盘。因为某种原因它不会滑动。。。当我点击箭头滑动我的
http://localhost:3000/
转到
http://localhost:3000/#carousel-通用示例

我相信我缺少必要的javascript需求,但不确定如何包含它们

它们放在什么档案里
application.js
application.css.scss
或在我的一个
视图中

另外,需要包含哪些代码,是否必须放在页面中的特定位置?它是
bootstrap.js
还是
bootstrap transition.js
还是其他什么?我真的迷路了

这是我的旋转木马,我相信它是正确的:

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

  <!-- Wrapper for slides -->
  <div class="carousel-inner">

    <div class="item active">
      <%= link_to image_tag("closeup.jpg", alt: "image", class:'img-responsive') %>
      <div class="carousel-caption">
        ...
      </div>
    </div>

    <div class="item">
      <%= link_to image_tag("parksolar.jpg", alt: "image", class:'img-responsive') %>
      <div class="carousel-caption">
        ...
      </div>
    </div>

    <div class="item">
      <%= link_to image_tag("big1.jpg", alt: "image", class:'img-responsive') %>
      <div class="carousel-caption">
        ...
      </div>
    </div>

  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>
</div>
这是我的application.css.scss(请注意,我还有一个导航栏,sass标记会影响我的旋转木马滑块吗?)

使用inspect element,我发现了以下错误:


它们是什么意思?

我想与大家分享,我已经通过使用

//= require jquery
//= require jquery_ujs
在上面

在Application.js文件中

试试这个,如果有用的话告诉我。
您可以在此处共享您的GEM文件内容吗?

使用chrome inspector(f12)并转到“网络”选项卡,检查是否正在加载您的所有文件,如果不检查此问题,则可能有助于加载文件您提供的链接没有答案。我使用的是rails 4。我只是想知道哪行代码应该包含javascript?Sry没有检查标签的版本。但查看屏幕截图很容易知道问题出在哪里,因为js文件对jquery具有硬依赖性,所以必须首先加载jquery。这很有效!你真是个天才!为什么必须这样做?首先应该是对jQuery有硬依赖关系的所有文件,而不仅仅是引导文件。这些文件甚至在加载之前就试图使用jQuery,这就是为什么必须这样做的原因。顺便说一句@Ritikesh good eye;)哈哈,谢谢@扎里奇。你的解释也很到位!:)有人能链接到一个文档或解释这种行为的东西吗。我会非常清楚这是怎么回事!
@import "bootstrap";

.navbar {
    border-radius: 0px;
    border-width: 0px;
    font-size: 16px;
    font-weight: bold;
    color: #f0ad4e;
    padding-left: 150px;
    padding-right: 150px;
    padding-top: 35px;
    margin: 0px;
    background:transparent;
}

.navbar-default .navbar-nav > li > a {
    color: white;
}

.navbar-default .navbar-brand {
    color: white;
}






/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 * 
 *= require_self
 *= require_tree .
 */
//= require jquery
//= require jquery_ujs
//= require bootstrap