【问题标题】:Bootstrap (JS/HTML CDN importing of JQuery) returns Uncaught ErrorBootstrap(JQuery 的 JS/HTML CDN 导入)返回未捕获错误
【发布时间】:2021-09-17 09:32:41
【问题描述】:

我正在尝试导入 jQuery,以便我可以使用引导下拉菜单,但我遇到了一些麻烦,因为我收到了错误:

Uncaught Error: Bootstrap's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0

虽然错误看起来合乎逻辑,但我不明白为什么它说我没有安装 jQuery,因为我明确地导入了它:

<head>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>

我在引导之前导入 jquery,所以我不明白是什么造成了错误。 这是电子应用程序的一部分,如果这有助于或与问题有关

非常感谢:)

【问题讨论】:

  • 请阅读this
  • 请查看您加载到 html 中的脚本/样式表的顺序。必须在脚本之前引用样式表

标签: javascript html jquery bootstrap-4


【解决方案1】:

下面的代码显示了 Bootstrap 4 的启动模板,可以在 here 找到。遵循此示例应该可以帮助您解决问题。请注意,脚本标记位于结束 &lt;/body&gt; 标记的正上方。列出脚本的顺序也很重要。

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>

【讨论】:

    猜你喜欢
    • 2016-02-17
    • 1970-01-01
    • 2012-09-27
    • 1970-01-01
    • 2020-08-16
    • 2018-11-01
    • 2016-12-14
    • 2018-09-25
    • 1970-01-01
    相关资源
    最近更新 更多