如何在Electron应用程序中实现JQuery和Bootstrap

时间:2016-12-29 08:59:32

标签: jquery twitter-bootstrap angular electron

在我认为Angular2-Electron应用程序已准备好投入生产并在途中遇到错误后,我将其打包了。出现的错误是我的引导带和JQuery无法找到。现在我通过node_modules将它加载到我的index.html中。这很有效,直到我不得不打包它。在本地加载JQuery和引导程序的最佳方法是什么,以便我的电子应用程序可以找到它? 我得到的错误是错误无法找到模块 我理解为什么会这样,因为当电子打包时,所有东西都被移动到一个文件中,我只是无法确定将bootstrap和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">

2 个答案:

答案 0 :(得分:2)

单独要求加载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引用中有一个double /)

答案 1 :(得分:0)

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

此链接可帮助jquery将项目与bootstrap元素同步,并仅与Internet连接一起使用。