javascript - Electron 应用程序中出现 Uncaught Error : Bootstrap's JavaScript requires jQuery at bootstrap. min.js :6,

标签 javascript jquery node.js angular electron

我建立了一个使用Angular框架的 Electron 应用程序。在“index.html”文件中,我加载了bootstrap和jquery。但是在使用electronic-packager构建了 Electron 应用之后。我看到这个错误。

Uncaught Error: Bootstrap's JavaScript requires jQuery
    at bootstrap.min.js:6
从该问题的先前答案中,我确保首先加载jquery,然后再加载 bootstrap 。但是我仍然看到这个错误
作为引用,我附上了index.html
<!doctype html>
<html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Demo App</title>
      <base href="./">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="icon" type="image/x-icon" href="favicon.ico">
      <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </head>
    <body>
    </body>
   </html>
但是,如果我在浏览器中以与Web应用程序相同的方式运行,则不会看到此错误。
注意:正如您在index.html中看到的那样,我正在将CDN用于jquery和bootstrap。
任何想法或建议将不胜感激。

最佳答案

我不建议使用CDN库,而是建议在Electron上使用jQuery npm软件包。
npm安装jquery

<script>
  window.$ = window.jQuery = require("jquery");
</script>

关于javascript - Electron 应用程序中出现 Uncaught Error : Bootstrap's JavaScript requires jQuery at bootstrap. min.js :6,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63191705/

相关文章:

javascript - 如何使 setTimeout 在上次单击 Toggle 时激活?

javascript - 如何让一个嵌入式函数运行多次

javascript - Docker-compose 不会将本地文件夹中的测试文件复制到 Container 中,而是复制其他所有内容

node.js - node-formidable 和一个简单的进度条

javascript - 当 Docker 使用端口时,Node.js 不会抛出 EADDRINUSE

javascript - d3 - 向路径添加标记

javascript - 使 Javascript/jQuery 下拉菜单在 IE6 中工作?

javascript - 设置 iFrame 源并使用 jQuery 重新加载

javascript - 如何从json文件中获取内容

javascript - AJAX POST 请求中的 HTTP 错误 400