【发布时间】:2018-05-15 16:52:21
【问题描述】:
在我的电子应用程序中,我正在设置一个 web 视图。这是 index.html 中的 sn-p:
<webview
class="hide"
preload="./preload.js"
nodeintegration
></webview>
<script>
require('./renderer.js');
</script>
在 main.js 中,我为 BrowserWindow 设置了 nodeIntegration:false,但应用程序无法启动,因为我在 webview 的控制台中收到此错误:
Uncaught ReferenceError: require is not defined
如果我从 main.js 中删除 nodeIntegration:false,它可以工作,但我不想公开节点 API。
(P.S.:webview指向的远程web应用正在使用jQuery。可能有冲突?)
【问题讨论】: