electron Uncaught TypeError: Cannot read property 'dialog' of undefined

electron Uncaught TypeError: Cannot read property 'dialog' of undefined

const remote = window.require('electron').remote;
const dialog =remote.dialog;//此行报错

网上说是electron为了安全默认是关闭的,所以要打开:

解决方法:

mainWindow = new BrowserWindow({
    600,
    height:800,
    /* 启用Node继承 */
    webPreferences:{
      nodeIntegration:true,
      enableRemoteModule:true
    }
  })

在background.js 中可能如下引用

import { dialog } from 'electron'
原文地址:https://www.cnblogs.com/xiaoruilin/p/15111962.html