...
大前端 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
闲来无事做个了微信多开工具,分享一下~ Chrome启动参数大全(命令行参数) 把废旧的电视机顶盒华为悦盒ec6108v9刷成Ubuntu系统做家用NAS php date 参数详解 一个小时学会Git