首页 文章

require()未在Electron HTML页面中定义

提问于
浏览
1

我目前无法在main.js文件之外的Javascript文件中加载Electron模块 .

我正在尝试使用:

const electron = require('electron');

const ipcRenderer = electron.ipcRenderer;

在名为settings.js的文件中 .

我安装了正确的NPM模块(eletron-prebuilt) .

设置页面加载在webview中,如下所示:

<webview id="settings" src="./settings.html"></webview>

和settings.js包含如下:

<script type='text/javascript' src='./resources/js/settings.js'></script>

这里没有想法,但我想知道这是否是某种范围问题?

非常感谢 .

1 回答

  • 3

    你_默认支持nodeintegration .

    nodeintegration 属性添加到您的webivew .

    <webview id="settings" src="./settings.html" nodeintegration></webview>
    

相关问题