Loading
柚木鉉の空間
0%
INITIALIZING
首页 文章 标签 归档 友链 推广 搜索
文档编号 // 40383F 在线

electron v11后,已经使用 nodeIntegration 但是报错未定义require

2021-05-29
更新: 2026-04-25
307 字符
这篇文章写于 2021,已经超过 5 年了。内容可能已经过时。

自从 electron 更新 11 后,contextIsolation: 被设置成默认 true, 需要配合使用。

function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
win.loadFile('index.html');
}
WeChat Pay 微信
Alipay 支付宝
导航 // 相关文章
目录