electron入门笔记(三)- 引入bootstrap
转载声明:
本文为摘录自“博客园”,版权归原作者所有。
温馨提示:
为了更好的体验,请点击原文链接进行浏览
摘录时间:
2020-06-06 15:34:59
源码:https://github.com/sueRimn/electron-bootstrap
当引入jQuery和bootstrap文件时,会报错,原因是:electron 的 Renderer 端因为注入了 Node 环境,存在全局函数 require,导致jquery 内部环境判断出现问题。
1、解决方法1:
再引入jQuery和bootstrap之前插入如下代码:
<script> delete window.require; delete window.exports; delete window.module; </script>
2、解决方法2:
前提是你必须能npm安装jQuery和bootstrap
先用npm安装好bootstrap和jquery,然后使用require来调用(如果无法安装,则加上–global参数),然后将HTML页面里面加入如下代码
<script> window.$ = window.jQuery = require('../node_modules/jquery/dist/jquery.min.js'); require('../node_modules/bootstrap/dist/js/bootstrap.min.js'); </script>