gpt4 book ai didi

jquery - Electron 应用的 Angular-CLI

转载 作者:行者123 更新时间:2023-12-03 12:24:45 25 4
gpt4 key购买 nike

我正在使用 Electron 和 Angular2(使用 Angular-Cli)开发一个桌面应用程序。

我想使用 Bootstrap,所以在我的 angular-cli.json 中,我将所需的脚本文件添加到了 apps[0].scripts 中,如下所示:

  "scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/toastr/build/toastr.min.js"
],

当我在网络上运行应用程序(使用 ng serve)时,一切正常。但是当我使用 Electron 运行应用程序时(首先是 ng build,然后从/dist 运行 Electron),我遇到了以下错误:
Uncaught Error :Bootstrap 的 JavaScript 需要 jQuery。 Angular 2 部分工作正常,路由工作正常, View 正确呈现等。

当我调查 scripts.bundle.js 时,包括了那些 3rd 方库。但是 Bootstrap 代码在 JQuery 之前。这就是我看到 Electron 错误的原因吗?

最佳答案

   <script>
try {
window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
} catch (e) {
}
</script>

将此添加到 index.html

关于jquery - Electron 应用的 Angular-CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40212097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com