...
大前端 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
electron 前端使用vue 或 webpack 打包一些问题整理 20 个实用的 JavaScript 单行代码 MacStroke下载及appleScript 模拟按键脚本 共享打印机0x0000011b修复的另一种方法 yarn 设置淘宝镜像 yarn 错误There appears to be trouble with your network connection. Retrying...