...
大前端 electronnodejs

electron渲染进程开启node及webview权限

electron 10以上渲染进程开启node能力的配置变了

contextIsolation: false,  //是否在独立 JavaScript 环境中运行
nodeIntegration: true, //是否完整的支持 node. 默认值为false   这个要打开才能在渲染进程使用node
enableRemoteModule: true,  //是否支持远程模块
webviewTag: true,  //是否支持webwiew标签

完整窗口创建代码:

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
        contextIsolation: false,
        nodeIntegration: true,
        enableRemoteModule: true,
        webviewTag: true,
        preload : path.join(app.getAppPath(),'preload.js')
    }
})
Electron V14 Electron Remote模块用法 CSS滚动条样式 CSS设置滚动条样式
biu biu biu
解决async await引发的Uncaught ReferenceError: regeneratorRuntime is not defined问题 css设置滚动条样式 electron创建圆角窗口附带阴影效果 electron 显示右键菜单 限制只对编辑框或选中文本显示右键菜单 js 返回并刷新 JavaScript 后退 刷新