如何在webview electronic中启用Node.js集成



每当我试图用webview加载一个HTML文件,该文件的javascript文件需要node.js时,node.js集成就无法工作(我只是尝试使用require(。

这是我的网页浏览代码

<webview id = 'frame' src = 'Home/home.html' style="max-width: 75%; min-width: 75%; height: 100%; padding-left: 10px; position:absolute; top:0; left: 175px;" nodeintegration></webview>

这是我的main.js网络偏好

webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: false,
webviewTag: true,
nodeIntegrationInWorker: true,
nodeIntegrationInSubFrames: true
},

我已经解决了这个问题,但集成node.js的方法是禁用上下文隔离,就像这个一样

<webview webpreferences = 'contextIsolation=false'></webview>

最新更新