【问题标题】:How to implement JQuery and Bootstrap in Electron app如何在 Electron 应用中实现 JQuery 和 Bootstrap
【发布时间】:2017-05-13 13:48:13
【问题描述】:

在我认为 Angular2-Electron 应用程序已准备好投入生产后,我将其打包,但在途中遇到了错误。出现的错误是找不到我的引导带和 JQuery。现在我正在通过 node_modules 将它加载到我的 index.html 中。在我不得不打包它之前,这很好用。在本地加载 JQuery 和引导程序以便我的电子应用程序可以找到它的最佳方法是什么? 我得到的错误是错误找不到模块 我理解为什么,这是因为当电子打包东西时,所有东西都被移动到一个文件中,我只是不知道何时何地将引导程序和 JQuery 加载到相应的位置

index.html:

 <script>window.$ = window.jQuery = require('../node_modules/jquery/dist/jquery.min.js');</script>

 <script src="../node_modules//bootstrap/dist/js/bootstrap.min.js"></script>

 <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">

 <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap-theme.min.css">

【问题讨论】:

    标签: jquery twitter-bootstrap angular electron


    【解决方案1】:

    仅需要加载 jquery 是不够的,您还必须在标签中额外引用您的文件:

    <script>window.$ = window.jQuery = require('../node_modules/jquery/dist/jquery.min.js');</script>
    <script src="../node_modules/jquery/dist/jquery.min.js"></script>
    

    您还应该确保所有路径都正确(您的 bootstrap.min.js 参考中有一个双 /)

    【讨论】:

    • 在此之前它是 100% 工作的,但我也这样做了,但仍然得到:
    • 我理解原因,这是因为当电子打包东西时,所有东西都被移动到一个文件中,我就是不知道何时何地将 bootstrap 和 jquery 加载到相应的位置跨度>
    【解决方案2】:

    script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"

    此链接可帮助 jquery 将您的项目与引导元素同步,并且仅适用于互联网连接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-30
      • 2022-08-03
      • 2020-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多