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({
    width:600,
    height:800,
    /* 启用Node继承 */
    webPreferences:{
      nodeIntegration:true,
      enableRemoteModule:true
    }
  })

在background.js 中可能如下引用

import { dialog } from 'electron'

 

posted @ 2021-08-07 15:02  三瑞  阅读(998)  评论(0编辑  收藏  举报