簡體   English   中英

未捕獲的錯誤:Bootstrap 的 JavaScript 需要 electron 應用程序中 bootstrap.min.js:6 處的 jQuery

[英]Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6, in an electron app

我已經構建了一個使用 Angular 框架的 electron 應用程序。 在“index.html”文件中,我加載了引導程序和 jquery。 但是在 electron 應用程序是使用電子打包器構建的之后。 我看到了這個錯誤。

Uncaught Error: Bootstrap's JavaScript requires jQuery
    at bootstrap.min.js:6

從之前對該問題的回答中,我確保先加載 jquery,然后再加載引導程序。 但我仍然看到這個錯誤

對於參考,我附上了 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 和引導程序。

任何想法或建議將不勝感激。

我建議不要使用 CDN 庫,而是在 Z0DF2DA9CF88450E045Z83 上使用 jQuery npm package。

npm 安裝 jquery

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

在 html 文件中添加以下腳本:

<!-- Insert this line above script imports  -->
<script>
  if (typeof module === 'object') {    window.module = module; module = undefined;  }
  </script>

然后添加腳本:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

然后添加以下內容:

<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM