【问题标题】:Bootstrap.js before jQuery.jsjQuery.js 之前的 Bootstrap.js
【发布时间】:2016-07-20 02:25:46
【问题描述】:

在我的页面上,我有 jQuery 手风琴和一个 Bootstrap 轮播。我在 bootstrap.js 之前包含了 jQuery.js。在这种情况下,手风琴将无法工作。

如果我在 jQuery.js 之前使用 bootstrap.js,手风琴将工作,但轮播将无法工作(这是由于未加载 jQuery 的事实)。

我已经看过了:Bootstrap.js has to load before jQuery 但我不是这样的。

据我了解,在 bootstrap.js 之前加载 jQuery.js 是正确的选择,但是我该如何让手风琴工作呢?

【问题讨论】:

  • 您确定您的页面上没有多个 jqueries 或引导程序吗?
  • 您使用的是哪个版本的 jquery?
  • 我正在使用 jquery-1.12.0
  • 我尝试使用 jquery 版本 1.9.0,然后轮播不起作用,但手风琴起作用。使用 jquery 1.12.0 则相反:(
  • 轮播不起作用如果 jquery 版本是(1.9.0 或更低)或(3.0.0 或更高)但如果 jquery 版本大于 1.9.0 且小于3.0.0。情况还是一样,只有其中一个(旋转木马和手风琴)有效,无论我使用什么版本的 jquery。

标签: jquery twitter-bootstrap carousel accordion


【解决方案1】:

有两个 jquery 库:

1。核心

2。界面

因此,顺序是:

  1. 加载jquery.min.js(核心)

然后:

  1. 导入bootstrap.min.js(你有轮播的地方)

那么,

  1. jquery.ui.js (UI)(你有手风琴的地方)

无论如何,我们建议在文档准备好时包装所有代码:

 $(function(){

     // All your code here
   
 })

试试这个并告诉我们:

    <link rel="stylesheet" href="https://code.jquery.com/ui/jquery-ui-git.css" media="screen" title="no title" charset="utf-8">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" media="screen" title="no title" charset="utf-8">


   <script src="https://code.jquery.com/jquery-2.2.1.min.js"
              integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s="
              crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script>
    <script  src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"
              integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E="
              crossorigin="anonymous"></script>

【讨论】:

  • Bootstrap3 不支持 jquery v3.0。目前它是 jquery: 1.9.1 - 2 参见 Docsissues
  • 我按顺序使用库 1.bootstrap.css 2.jquery.js 3.bootstrap.js 4.jquery-ui.js 5.jquery-ui.css 然后我有自己的脚本
  • 我尝试了上述库,但轮播在这种情况下不起作用。
  • 再次复制库,因为我做了更改.. 再试一次,告诉我 plz (jquery 3==> jquery2)
  • 你在哪里改变了 jquery 3==> jquery2 ?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多