![](/img/trans.png)
[英]bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6
[英]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.