由于某种原因,引导程序不允许我在js中设置间隔时间。

我正在使用Middleman将我的静态网站提供给localhost,但似乎无法使js从引导程序中影响轮播。我像这样加载了引导程序和自定义js

!!!
%html
  %head
    %title Save Rosie
    %meta{charset: "utf-8"}/
    / Always force latest IE rendering engine or request Chrome Frame
    %meta{content: "IE=edge,chrome=1", "http-equiv" => "X-UA-Compatible"}/
    / Use title if it's in the page YAML frontmatter
    = stylesheet_link_tag "fonts", "all", "bootstrap"
    = javascript_include_tag  "jquery-1.11.0.min", "all", "bootstrap"
  %body{class: page_classes}
    = yield


轮播功能齐全

.carousel.slide{ "data-ride" => "carousel" }
      .carousel-inner
        .item.active
          %img{ :src => 'https://s3-us-west-2.amazonaws.com/rosiesdonations/Rosie1.png', :alt => "Rosie Picture one" }
        .item
          %img{ :src => 'https://s3-us-west-2.amazonaws.com/rosiesdonations/Rosie2.jpg', :alt => "Rosie Picture two" }
        .item
          %img{ :src => 'https://s3-us-west-2.amazonaws.com/rosiesdonations/Rosie3.jpg', :alt => "Rosie Picture three" }


但是当我打电话

$('.carousel').carousel({
  interval: 2000
})


在all.js中,它不会在2秒时切换,而是默认5秒。

寻找错误:Uncaught TypeError:对象[object Object]没有方法'carousel'

我尝试先加载引导程序,但没有成功。

最佳答案

在脚本中,bootstrap.js必须在all.js之前。

10-06 04:26
查看更多