我正在努力学习电子框架,但我在index.html中访问index.html时遇到了一些问题。我得到的错误是:
未定义
'require()‘
我已经用npm安装了jQuery:
npm install jquery --save比我试图在我的index.html中使用它:
window.$ = window.jQuery = require("jquery");据我所知,直接访问节点模块存在一些安全问题吗?如果有人能向我展示如何使用jquery的正确方法,我会非常精通的。
发布于 2022-10-08 17:50:03
将nodeIntegration: true和contextIsolation: false添加到BrowserWindow中的webPreferences中。就像这样。
let mainWindow = new BrowserWindow({
..........
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});https://stackoverflow.com/questions/73999252
复制相似问题